without using a cronjob how would I have a ubuntu server shutdown after 2 days (2880 minutes) at midnight?

The essence of what I want to do is this:

bash shutdown -r +2880 00:00 which would tell shutdown to shutdown after 2880 minutes, but to make sure that it is midnight before actually shutting down.

  • What exactly do you need? You want it to shutdown on the first midnight that is at least 2880 minutes in the future? That might mean it will shutdown three days from now if the current time is 23:59. Or do you want it to shutdown on exactly midnight the day after tomorrow even if 2880 minutes have not passed? – terdon Oct 22 '13 at 23:08
  • 1
    I don't know the syntax offhand, but in an RPM I built for work, I used the at command to do something two minutes in the future. Basically, if apache was running, I shut it down and tell it to start in two minutes. Then I do all my config tweaking, etc. and know it will come back later. – Aaron D. Marasco Oct 23 '13 at 0:16

Use the at command ? I'm a similar way to terdons answer but used instead of sleep. It doesn't require your shell to be left open

Echo "shutdown -h 00:00"|at now + 2 days

For example


If all you want is to shutdown on the first midnight that is at least 2880 minutes in the future, do this (as root):

sleep 2880m; shutdown -h 00:00 

sleep just causes the shell to wait the specified amount of time (2880 minutes in this case). Once the sleep command has finished, the shutdown is called for midnight.

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.