Schedule Shutdown and start up on specific dates

Nape Dog

macrumors newbie
Original poster
Sep 26, 2012
7
0
Morning all
I am going away for a couple of weeks and I need to keep my mac on for remote access.
That said, there will be an electrician doing some work on one of those days which will involve the power in the house being shutdown.
I want to be able to schedule my mac to shut down the night before he comes and to restart itself the the morning after he has been.
this will need to happen on 2/3 occasions so the basic energy saver options don't give enough flexibility.
Does anyone know how i can do this?
Many thanks
 

rkaufmann87

macrumors 68000
Dec 17, 2009
1,760
38
Folsom, CA
Morning all
I am going away for a couple of weeks and I need to keep my mac on for remote access.
That said, there will be an electrician doing some work on one of those days which will involve the power in the house being shutdown.
I want to be able to schedule my mac to shut down the night before he comes and to restart itself the the morning after he has been.
this will need to happen on 2/3 occasions so the basic energy saver options don't give enough flexibility.
Does anyone know how i can do this?
Many thanks
In Energy Saver you can schedule a Startup or Wake time, however it's designed to be done on a routine basis. I suspect this would be simple task for Automator though however it's up to you to write the routine.
 

Nape Dog

macrumors newbie
Original poster
Sep 26, 2012
7
0
Thanks. That's what I thought but I don know how to do it and as I'm going tomorrow I'm short of time to try and work it out.
Anyone else out there know where to start?
Thanks
 

azentropy

macrumors 68020
Jul 19, 2002
2,198
1,165
Surprise
Thanks. That's what I thought but I don know how to do it and as I'm going tomorrow I'm short of time to try and work it out.
Anyone else out there know where to start?
Thanks
You could script different settings and use some sort of scheduler (cron) to execute the settings on the days you want them.

You can even schedule certain activities on certain times, but not sure if it allows multiple. So again you would have to schedule settings. You would also need to run as root...

pmset is the command you would want.
 

Nape Dog

macrumors newbie
Original poster
Sep 26, 2012
7
0
You could script different settings and use some sort of scheduler (cron) to execute the settings on the days you want them.

You can even schedule certain activities on certain times, but not sure if it allows multiple. So again you would have to schedule settings. You would also need to run as root...

pmset is the command you would want.
thanks. but i think this may be too much for me to handle
 

azentropy

macrumors 68020
Jul 19, 2002
2,198
1,165
Surprise
thanks. but i think this may be too much for me to handle
No problem. It is probably more simple than you realize, have you used Terminal at all before?

Basically launch terminal and then do
sudo su -

and then you can use the pmset commands to do one time scheduling...

pmset schedule sleep "05/31/13 08:00:00"
pmset schedule wake "05/31/13 08:15:00"

thats it...

You could also set up as a applescript applet, but that is actual a bit more work.
 
Last edited:

leman

macrumors G4
Oct 14, 2008
10,282
4,803
thanks. but i think this may be too much for me to handle
EDIT: I have just tried it out and edited my post accordingly

pmset is actually very easy to use! Read up the section on the scheduled actions! I tried this in Terminal:

Code:
 sudo pmset schedule shutdown "05/31/13 17:41:00"
 sudo pmset schedule poweron "05/31/13 17:42:30"
and it worked like a charm. The sudo part is to run the pmset command as an admin (it will promt you your password). Make sure that you are not running any application that might potentially cancel the shutdown (like editors with unsaved data) - I have no idea whether the shutdown will be forced. Also, the system will wait 10 minutes before actually shutting down the machine to allow user reaction - so make sure you set your times generously.

Try it out, its great fun ;)

EDIT 2: azentropy beat me to it while I was experimenting ^^
 
Last edited:

Nape Dog

macrumors newbie
Original poster
Sep 26, 2012
7
0
Great thanks for your help on this.
so I:
Enter terminal
type: sudo su -
type: sudo pmset schedule shutdown "06/03/13 08:00:00" and press enter

and this should automatically shut it down at 8am on 3rd June 2013?

then to schedule the restart at 6pm on 3rd June I type
sudo pmset schedule poweron "06/03/13 18:00:00" and press enter

that seems easy enough
thanks a lot. i'll give it a whirl now.



EDIT: I have just tried it out and edited my post accordingly

pmset is actually very easy to use! Read up the section on the scheduled actions! I tried this in Terminal:

Code:
 sudo pmset schedule shutdown "05/31/13 17:41:00"
 sudo pmset schedule poweron "05/31/13 17:42:30"
and it worked like a charm. The sudo part is to run the pmset command as an admin (it will promt you your password). Make sure that you are not running any application that might potentially cancel the shutdown (like editors with unsaved data) - I have no idea whether the shutdown will be forced. Also, the system will wait 10 minutes before actually shutting down the machine to allow user reaction - so make sure you set your times generously.

Try it out, its great fun ;)

EDIT 2: azentropy beat me to it while I was experimenting ^^
 

azentropy

macrumors 68020
Jul 19, 2002
2,198
1,165
Surprise
Great thanks for your help on this.
so I:
Enter terminal
type: sudo su -
type: sudo pmset schedule shutdown "06/03/13 08:00:00" and press enter

and this should automatically shut it down at 8am on 3rd June 2013?

then to schedule the restart at 6pm on 3rd June I type
sudo pmset schedule poweron "06/03/13 18:00:00" and press enter

that seems easy enough
thanks a lot. i'll give it a whirl now.
Basically - yeah. On thing to note though is it does give a 10 minute window to cancel, so you might want to start 10 minutes early.

Also if you do the "sudo su -" first you don't have to do use sudo for the other commands. Or if you don't do "sudo su -" first it will just prompt for your admin password for the other commands.

Try it with the sleep and wake first to see how it works for you.
 

drambuie

macrumors 6502a
Feb 16, 2010
751
0
The problem with scheduling shutdowns and startups is that you will be depending on the electrician showing up on the scheduled days and times, and not exceeding the shutdown periods for the work.

The best solution, with complete flexibility, would be to use a UPS. When the power is cut the UPS will signal the iMac for OS X to perform an orderly shutdown a predetermined number of minutes after power loss, then restart to the previous state after power restoration. It would also cover you for unexpected power interruptions while you're away.

For an iMac a sinewave UPS would be preferred, such as a CyberPower 1350PFCLCD, or 1000PFCLCD.
 

Nape Dog

macrumors newbie
Original poster
Sep 26, 2012
7
0
Thanks. You're probably right but ill have to run with this as its my best hope. Thanks for the tip on UPS. Ill consider one of those for the future.

The schedule command seems to work so thanks for your help chaps

----------

Am I able to cancel a command for a scheduled shutdown?
 

azentropy

macrumors 68020
Jul 19, 2002
2,198
1,165
Surprise
Thanks. You're probably right but ill have to run with this as its my best hope. Thanks for the tip on UPS. Ill consider one of those for the future.

The schedule command seems to work so thanks for your help chaps

----------

Am I able to cancel a command for a scheduled shutdown?
Yes, just add the cancel to the command.

so if you previously had done:
sudo pmset schedule shutdown "06/01/13 08:15:00"
you could do this to cancel it:
sudo pmset schedule cancel shutdown "06/01/13 08:15:00"

you can also check your scheduling by doing:
sudo pmset -g sched