Scheduled Reboot Package?

Is there a package available that will add a reboot schedule option to the LuCI GUI? I am using LEDE Reboot 17.01.2. Thanks.

1 Like

You should not need to reboot your device on a schedule... I guess most developers would work to fix the issue rather than create a new package, so it is unlikely that it exists. If you can execute a reboot command and it works as expected, you can go to the "System > Scheduled tasks" page and add it there.

For the syntax you should check out how a crontab file has to look like. It has six fields (minute, hour, day of month, month, day of week). So if you want to reboot our router every day at 4.30 in the morning you write somehing like:

30 4 * * * * reboot

Btw, you can also access this file on the console with crontab -e.

actually five fields (like you listed in text).

@mrroute
Please also read the advice from wiki (about avoiding reboot loop):

https://wiki.openwrt.org/doc/howto/cron#periodic_reboot_of_a_router

this is not as simple as it seems, becomes router usually have no real-time clock. This could lead to a never-ending loop of reboot.

In the boot process the clock is initially set by sysfixtime to the most recent timestamp of any file found in /etc. The most recent file is possibly a status file or config file, modified maybe 30 seconds before the reboot initiated by cron. So, in the boot process the clock gets set backwards a few seconds to that file's timestamp. Then cron starts and notices a few seconds later that the required boot moment has again arrived and reboots again… (At the end of the boot process ntpd starts, and it may also take a while before ntpd gets and sets the correct time, so cron may start the reboot in between.)

One solution for cron is to use a delay and touch a file in /etc before reboot:

# Reboot at 4:30am every day
# Note: To avoid infinite reboot loop, wait 70 seconds
# and touch a file in /etc so clock will be set
# properly to 4:31 on reboot before cron starts.
30 4 * * * sleep 70 && touch /etc/banner && reboot
4 Likes

Thanks for these tips. I will probably just reboot manually as needed. If I decide to do this, do I just copy and paste that block of text in the scheduled tasks textbox and hit submit?

Only the last line is needed, the actual cron line

And you to restart the cron service.

I wonder if

30 4 * * *  [ $( cat /proc/uptime | cut -d '.' -f 1 ) -gt 3600 ] && reboot

isn't a better solution. No matter if ntp works, and the quality of your timeserver, it can never reboot more often than once an hour, and it doesn't wear out the flash.

1 Like

Cron job is optimal, but watchcat is available for anyone who still wants a package.

Does Watchcat just give you an interface for this?

1 Like

Sorry @mrroute but I don't know, I don't use it myself, I just remember that it will perform a scheduled reboot or a reboot after connection is lost.

Hello everyone, everything good?

I would like to know how I program cron to restart my routers at 11:59 PM on 12/31.

Right now, thank you very much and Happy New Year to everyone!

everything was good even before this thread existed.
but since it does, read it

Happy New Year

1 Like