Linux shutdown in 30 seconds?

In OS X you can shutdown in one minute using the following command:

sudo shutdown -h +1

AFAIK, it's not possible to specify seconds instead of minutes with this command.

You can also reboot by using -r instead of -h.


EDIT:

As you mentioned in your comment, you can add a delay programmatically, then shut down the system immediately with

shutdown -h now

But note that that command will require root access.


Using the basic calls, I don't see a way to do it with seconds, but it looks like you can do it with minutes:

time Time is the time at which shutdown will bring the system down and
     may be the word now (indicating an immediate shutdown) or specify
     a future time in one of two formats: +number, or yymmddhhmm,
     where the year, month, and day may be defaulted to the current
     system values.  The first form brings the system down in number
     minutes and the second at the absolute time specified.

In other words:

shutdown -h +1

If you want to shut it down in 1 minute.


As pointed out, the command

sudo shutdown -h +1

Adds one minute.

If you wanted to do it in seconds or hours or something very specific you could do something like:

shutdown -h `date --date "now + 60 seconds"`

EDIT: The above no longer works on more recent builds of Ubuntu. Thanks for pointing that out @zitrax. My mistake you're right.

But you can still do it but it seems maybe to the nearest minute.

sudo shutdown -h `date --date "now + 10 minutes" "+%H:%M"`

Which is somewhat pointless when the +m parameter is easier to type.... ahhh oh well.