-2

I am using ubuntu server 14.04, Now downloading in process and i am leaving office. I want to shut it down after 2 hours. please help me, how to do it.

This didn't work for me.

sudo shutdown -P 60
  • 1
    Just out of curiousity, what do you think 60 means in this context? – maulinglawns Nov 17 '16 at 12:08
1

From man shutdown:

The time string may either be in the format "hh:mm" for hour/minutes
specifying the time to execute the shutdown at, specified in 24h clock
format. Alternatively it may be in the syntax "+m" referring to the
specified number of minutes m from now.  "now" is an alias for "+0",
i.e. for triggering an immediate shutdown. If no time argument is
specified, "+1" is implied.

So it seems you're missing a + (and presumably you mean 120)

| improve this answer | |
0

You can use corn job to shutdown. The time and minutes you want to shutdown can be specified as below.

sudo /etc/crontab:

30 21 * * * root shutdown -h now

Above entry will run shutdown command at 21:30.

cron format:

MM HH DD OO WW command MM: Minute, 0-59 HH: 24-hour hour DD: Day of month OO: Month WW: Day of Week (Sunday is 0, Monday is 1) command: Self-explanatory

| improve this answer | |
  • 1
    Using a cron job in this context makes no sense. OP wanted to shut down the computer after 2 hours now. The shutdown command does that, cron will do that, but repeatedly! – maulinglawns Nov 17 '16 at 12:54
  • To avoid cron job running repeatedly he can delete the crontab entry tomorrow. – Aspire Nov 17 '16 at 13:09

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.