Use cron, i can't understand why need to exec sleep 70 && touch /etc/banner

i cant understand why need to exec sleep 70 && touch /etc/banner , pls, Explain more popularly Thanks!

1 Like

I think you're asking about automatic reboots. The idea is that if you reboot then when the machine restarts it will have a time equal to the most recently touched file until it's been able to update its time via the internet. This can cause cron to run your job again... rebooting again, in a loop.

3 Likes

I really want to ask for automatic reboots, But after i see your explains, i still can`t understand why it is? Could you make it more simpler?
Thanks!

There is no (battery-backed) real-time clock in most routers. Time is initialised at boot with file timestamps. Finding the current time from internet with NTP can take time. Without waiting and then touching a file, the router might start from the same time and cron might cause a new reboot.

Waiting 70 seconds before touching a file ensures that the timestamp of that file is after the cron scheduled reboot time. (OpenWrt also avoids writing to flash during the normal operations, so touching a file ensures that the clock starts with a reasonably ok time)

https://openwrt.org/docs/guide-user/base-system/cron#periodic_reboot

Original advice from me in 2014 in discussion here..
https://forum.archive.openwrt.org/viewtopic.php?id=54227

5 Likes

Thanks, i know it! why openwrt use the Strategy about After boot the clock initially starts from the most recent timestamp of any file in /etc?
Is there a document that explains this?

The path should be persistent to provide reliable update and predictable result.
Otherwise something can confuse the system with modification time set in the future.