4

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
reboot

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

2
  • Does it have to be 60 seconds after completing startup, or 60 seconds after the last reset? Commented Jun 3, 2015 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
    Commented Jun 3, 2015 at 22:19

4 Answers 4

9

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

1
  • 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
    Commented Jun 16, 2015 at 17:51
3

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.

1
  • 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
    Commented Jun 16, 2015 at 18:50
1

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

0
[root@linux]crontab -e

Then append this line:

* * * * * /sbin/reboot

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

Good luck!

You must log in to answer this question.

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