Modify

Opened 3 years ago

Last modified 3 years ago

#18670 new defect

Cron constantly reboots device running openwrt

Reported by: azur.muhic@… Owned by: developers
Priority: response-needed Milestone: Barrier Breaker 14.07
Component: packages Version: Barrier Breaker 14.07
Keywords: cron reboot Cc:

Description

Hello to all,

I recently discovered a possible bug in cron while scheduling reboot task. Cron reboots router at the scheduled time, and (strangely) starts to reboot router every minute or two constantly after first (scheduled) reboot no matter what. It stops when I delete scheduled task. I'm using a very simple command: 0 3 * * 0 reboot. Using Barrier Breaker 14.07 and tp-link wr841n

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by jow

  • Priority changed from normal to response-needed

Please check if the issue is solved after "/etc/init.d/sysfixtime disable"

comment:2 Changed 3 years ago by hnyman

The router has usually no real-time clock. In the boot process the clock is initially set by "sysfixtime" to the most recent timestamp of any file found in /etc. At the end of the boot process ntpd starts and fetches the correct time from internet. You may notice this time jump in the system log, although ntpd starts so late that there might not be anything in the log after that.

The most recent file in /etc is possibly a status file, config file or something, modified maybe 30 seconds before the boot. So, in the boot process the clock gets set backwards a few seconds to that file's timestamp. And then cron starts and notices a few seconds later that the required boot moment has again arrived and reboots again... (ntpd starts later and it may take a while before ntpd gets and sets the correct time, so cron may start the reboot in between.)

Alternative solution for cron (instead of disabling sysfixtime like Jow proposed):

Use a delay in cron 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

Related discussion:
https://forum.openwrt.org/viewtopic.php?pid=255592#p255592
https://forum.openwrt.org/viewtopic.php?pid=233054#p233054

comment:3 Changed 3 years ago by hollari@…

Would there any possibility to start the cron daemon after the time is set correctly (by ntp) ?
(i.e. set the time and date to something like 1970, and make the crond wait until the date is e.g. at least from 2015 ?!?)

comment:4 Changed 3 years ago by anonymous

What happens if there is no connectivity? Crond would never get started then.

comment:5 Changed 3 years ago by anonymous

Thats true.
If you want your Router to do something at least 24 hours after it has
started, this would be bad.

But there are many other appliacations where - i think - its better to
do nothing, if the time is incorrect.
(e.g. periodic data collection of some input that comes from USB-Serial-Adapters)

Maybe crond could set at least a environment variable, that tells
a script that the time is most propably incorrect for this case ?

On the other hand arent there some extra cronjobs that are executed
every SECOND, MINUTE, HOUR ... and so on that could do this job ?

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.