systemd system to schedule daily reboot

Viewed 60

I want to schedule a daily reboot on ubuntu core. There is no cron on ubuntu core.

But I can use systemd services

I have created a reboot.service and a reboot.timer

[Unit]
Description=reboot servuce
Requires=reboot.service

[Timer]
Unit=reboot.service
OnBootSec=2min
# every day at 4am
OnCalendar=*-*-* 4:00:00

[Install]
WantedBy=basic.target

But the problem this is executed on reboot. So there is reboot loop.

How do I avoid this.

I can write a reboot script that checks the last reboot time and only reboots if 24 hours has passed. Is there a better way?

0 Answers
Related