Rebooting Linux from script

Solution 1:

I've found (tested on Raspbian) that the shutdown command works as expected, but the key thing is that the calling script must not exit before the timer elapses. So I added a sleep command:

shutdown --reboot 1 "System rebooting in 1 minute"
sleep 90

Solution 2:

Hell of a way to reboot it is to use

reboot -f

But this will reboot your machine in 3 seconds without gracefully stopping any services\apps, so you might consider another way around.

Also shutdown may not recognize the "-t" argument, taking the time argument like this instead:

shutdown -r 10 //reboot in 10 minutes

Anyways, man shutdown may come in handy. It does not appear that shutdown accepts anything less than minute resolution, but your milage may vary.