Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
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

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.