I am debugging some embedded hardware that runs Linux 3.2.6 Angstrom distro, I need the unit to reboot every 60 seconds. I tried this:

In /etc/rc5.d : S99reboot -> /home/root/test.sh
/home/root/test.sh contains only this: /home/root/rebootunit.sh&
/home/root/rebootunit.sh has this:
echo "sleep 60 and reboot"
sleep 60

works fine from the command line, but when run from startup, the unit starts to shutdown, then gets stuck with this:

Deactivating swap...
Unmounting local filesystems...

Give root password for system maintenance
(or type Control-D for normal startup):

And the filesystem is in read-only mode. I'm not sure why this happened, or if there is another way to do this - I'm open to suggestions, thanks

  • Does it have to be 60 seconds after completing startup, or 60 seconds after the last reset? – Gilles 'SO- stop being evil' Jun 3 '15 at 22:09
  • 3
    Random guess: Fire it off as a background process (sleep 60 && reboot) & so your init script finishes. Maybe it's not happy that you tried to reboot before your script (and thus the boot) was done. – derobert Jun 3 '15 at 22:19

I would put

* * * * * /sbin/reboot

in root's crontab.

Clarification: since cron doesn't run until the system is fully up, you don't get conflicts between startup and shutdown procedures.

|improve this answer|||||
  • Ok - finally got cron installed - but it's not working at startup, only if I restart it? I'm going to post as a separate question. Thanks! – Jeff Jun 16 '15 at 18:50

Append shutdown -r 60 to /etc/rc.local.

|improve this answer|||||
  • As far as I can tell /etc/rc.local is not getting called, only the things in /etc/rc5.d get called. Maybe something about this distro? Here's my attempt: root@SL1000-1103DC:~# cd /etc root@SL1000-1103DC:/etc# ls -l rc.local -rwxr-xr-x 1 root root 23 Jun 16 13:47 rc.local root@SL1000-1103DC:/etc# cat rc.local echo "Hello rc.local" – Jeff Jun 16 '15 at 17:51

It would be good to issue the reboot command only after the system is fully booted and all boot activities are complete. Using rc.local is a good idea but the fact that it is a foreground command might still be a problem. So backgrounding the command might also be a good idea.

shutdown -r 30 &

Or issue an at job (from rc.local) that does it outside the start-up scripts:

at -f /home/root/test.sh now

|improve this answer|||||
[root@linux]crontab -e

Then append this line:

* * * * * /sbin/reboot

It will create new cron job that reboots your machine every minute.

Good luck!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.