Reboot schedule (shorten the wait time)

# 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

sleep 70
does this value halt the router for 70 seconds (before it actually turns on)?

could i shorten it to say 15 seconds?
sleep 15

The comments above the cron job tell you the reason for the wait time, it's intentionally set to a time longer than the 'normal' boot time.

…but there's always the option to start your cron job a minute earlier.

so the router will be offline for about 70 seconds?
Thats a 1 minute and 10 seconds.
plus maybe a 30 seconds for the booting process.

correct?

No, it will be offline for whatever time it needs to shut down, pass through its bootloader and boot again. It will just wait 70s before doing anything (as in invoking the reboot procedure).

The concept of daily precautionary reboots however is flawed to begin with, either your router and its firmware are stable - then it doesn't need to be rebooted just in case, or it's not - in which case it's defective.

1 Like

once the router has properly rebooted.
the wifi connection will be OK?
users can connected to the wifi?
the sleep 70 is just for the time sync?

Imagine your router reboots at 4:30:00 - and lets say it takes 20 seconds to reboot

4:30:20 - it's now 4:30:20 - so the hours/minutes match the crontab entry - so - it will reboot

now it's 4:30:40 - so the hours/minutes match the crontab entry - so - it will reboot

At least that MAY be how cron works

waiting 70 seconds means that by the time reboot begins, it definitely WONT be 4:30 any more

The sleep is for that "process" ... i.e. it's a standard *nix "wait" in a shell script for example - it doesn't pause the whole device

the TL;DR - your router will reboot at 4:31:10 or so without any adverse effect between 4:30:00 and 4:31:10

2 Likes

so basically this command

30 4 * * * sleep 70 && touch /etc/banner && reboot

will reboot the router at exactly 4:31:10 am?

so if i want it to reboot at exactly 4:30 am
i need to move it back?

like this?

29 4 * * * sleep 60 && touch /etc/banner && reboot

Yes - and cron isn't that exact in my experience anyway - with that entry, the reboot will take place at 4:30ish - it could be exactly 4:30 ... or a few seconds later, or even earlier if you measure against an atomic clock with the precise time

Do you really need to reboot the router at EXACTLY 4:30am? down to the second?

28 4 * * * sleep 120 && touch /etc/banner && reboot

i used this instead

yes i need to reboot daily as these AP are public (with no security)
sometime the devices has problems with the wifi
fresh reboots daily almost solves all problems

I know you say you need to reboot daily ... I asked if the reboot time needs to be EXACTLY 4:30 .. i.e 4:31 is no good

Also, rather than rebooting, you could restart just the wifi - /sbin/wifi reload - I have a device I used to reboot like you do, but found that it's really only the wifi needs restarting

Just to throw this out there... why are you scheduling daily reboots? As a general rule, this should not be necessary. And if it is necessary because your router is experiencing issues, you are better served by solving the root cause of those problems rather than masking it by simply rebooting the router.

1 Like

Usually OpenWRT solves the memory leak faults original firmwares have from time to time that usually makes the device stop in a couple of days. And memory leaks is usually solved with a reboot.

The other reason I have heard to make daily reboot is to remove “daily malwares” that lives in the memory. But just using a modern openwrt version that still is updated and has a “healthy setup”, then malware is not very common topic in this forum?

And network linux based devices/servers are kind of supposed to be run 24/7 which makes a daily reboot strange to begin with.

I had for about 10years ago a router that loosed the speed all the way down to 0 over a couple of days. But I simply used a power socket day timer and cut the power every night to solve the issue. That is probably the easiest solution for a daily reboot that doesn’t care of this cron “back to the future” paradox. But you should still let it run dry of electricity for at least 30seconds so the memory is cleared.