1

For some testing, I need to reboot my system every minute. I have a busybox based system, installed cron using opkg. I setup a cron job using crontab, everything looks ok:

root@SL1000-1103DC:~# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.1962 installed on Tue Jun 16 14:57:01 2015)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
* * * * * /sbin/reboot

root@SL1000-1103DC:~# 

But the command is never run after the system boots? However, if I restart cron, then everything works:

root@SL1000-1103DC:~# /etc/init.d/cron restart
Stopping Vixie-cron.
Starting Vixie-cron.
root@SL1000-1103DC:~# date
Tue Jun 16 14:58:18 EDT 2015
root@SL1000-1103DC:~# 
Broadcast message from root (Tue Jun 16 14:59:00 2015):

The system is going down for reboot NOW!
INIT: Switching to runlevel: 6

So is there something different about running cron at startup, versus running from a command line? Maybe some subtle permissions issue? All of this is done at root level. Hmmm....

Edit: More info - looks like the unit is rebooting at odd times, as if cron was confused about the time? I left it alone, and it rebooted several times. Last time I had tail on /var/log/messages, and I see a message from cron issuing the command. So now the question is - why is cron confused about the time?

6
  • Have you confirmed that cron really started at boot?
    – Jeff Schaller
    Jun 16, 2015 at 19:52
  • Looks like it has: root@SL1000-1103DC:~# ps | grep cron 1245 root 1800 R /usr/sbin/cron 1962 root 2892 S grep cron Also I see it in the startup log
    – Jeff
    Jun 16, 2015 at 21:26
  • Re: odd reboot times, is there a time service (eg ntp) that also starts at boot time that would be changing the time under cron?
    – Jeff Schaller
    Jun 16, 2015 at 21:46
  • Definitely yes - the unit has no RTC, so it goes out and gets the current time - so that's likely the problem? Any ideas on a solution?
    – Jeff
    Jun 16, 2015 at 22:25
  • Short version- make cron start after ntp, and make ntp sync quickly (assuming you'll continue to reboot every 60 seconds). If you want more detail, let me know.
    – Jeff Schaller
    Jun 16, 2015 at 22:33

1 Answer 1

0

Sounds like cron was started before the time synchronization had settled, so the fix is to sync the time before cron starts.

1
  • Exactly right! Our system boots with a time in 2004, and cron seems to get confused when the time eventually gets set correctly. Made cron last in startup, after time had settled, and all good.
    – Jeff
    Jun 17, 2015 at 2:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .