OpenWrt Forum Archive

Topic: My monthly cron reboot won't stop rebooting.

The content of this topic has been archived on 27 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm running Barrier Breaker on a TP-LINK TL-WDR3500 and I want it to reboot automatically once per month so I added the following to /etc/crontabs/root:

0 0 11 * * reboot

It reboots automatically at the correct time but then about a minute after it starts it reboots again in a never-ending cycle.

If I power it off and power it on manually then the cycle is broken and it doesn't reboot itself.

Any ideas about what could be happening or how I can debug this?

My guess:
during the boot process the router sets the time based on the last timestamp of any file in /etc directory. Sysntpd starts rather late, so it is quite possible that when cron gets started, the router still thinks that the time is 23:59:00 or something like that (in case there has been no file activity in /etc immediately before the reboot). And midnight arrives then after one minute uptime, and it is time to boot again :-)

You might check what is the time right after the boot (with logread, uptime, time or whatever).

Suggested cure:
create a script to be run with cron.
In the script
- sleep 5 seconds
- touch /etc/banner   (to set its timestamp to 00:00:05)
- reboot

(Last edited by hnyman on 11 May 2014, 20:32)

Does this work or provide clues?

1 0 11 * * echo date >> /somewhere/boot.log ; reboot

hnyman wrote:

You might check what is the time right after the boot (with logread, uptime, time or whatever).

Suggested cure:
create a script to be run with cron.
In the script
- sleep 5 seconds
- touch /etc/banner   (to set its timestamp to 00:00:05)
- reboot

The time does jump after boot!  It's set to the time that I last changed /etc/crontabs/root and then after a minute or so it's corrected to the real time (via NTP presumably) and it reboots.

Your cure worked, thank you!

Wouldn't it just make more sense to start cron after sysntpd?  Actually that wouldn't work because it would have to be started after time synchronization, not after the /etc/init.d/sysntpd script executes.

(Last edited by NodeGuy on 11 May 2014, 23:51)

why have it reboot monthly?

I'm rebooting it monthly because I'm implementing the immutable server pattern.  I'm storing the configuration for the router in a private Bitbucket Git repository.  When the router reboots it erases itself, clones the repository, and runs a provisioning script from the repository.

I've installed the router in a remote location without physical access.  This process gives me confidence that I can update the configuration as needed simply by pushing new changes to the Git repository, and that it if gets itself into any trouble then it will get a fresh start at least every month.

The discussion might have continued from here.