Schedule Shutdown and start up on specific dates

Discussion in 'iMac' started by Nape Dog, May 31, 2013.

  1. Nape Dog macrumors newbie

    Joined:
    Sep 26, 2012
    #1
    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
     
  2. rkaufmann87 macrumors 68000

    rkaufmann87

    Joined:
    Dec 17, 2009
    Location:
    Folsom, CA
    #2
    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.
     
  3. Nape Dog thread starter macrumors newbie

    Joined:
    Sep 26, 2012
    #3
    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
     
  4. azentropy macrumors 68000

    azentropy

    Joined:
    Jul 19, 2002
    Location:
    Surprise
    #4
    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.
     
  5. Nape Dog thread starter macrumors newbie

    Joined:
    Sep 26, 2012
    #5
    thanks. but i think this may be too much for me to handle
     
  6. azentropy, May 31, 2013
    Last edited: May 31, 2013

    azentropy macrumors 68000

    azentropy

    Joined:
    Jul 19, 2002
    Location:
    Surprise
    #6
    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.
     
  7. leman, May 31, 2013
    Last edited: May 31, 2013

    leman macrumors 604

    Joined:
    Oct 14, 2008
    #7
    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 ^^
     
  8. Nape Dog thread starter macrumors newbie

    Joined:
    Sep 26, 2012
    #8
    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.



     
  9. azentropy macrumors 68000

    azentropy

    Joined:
    Jul 19, 2002
    Location:
    Surprise
    #9
    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.
     
  10. drambuie macrumors 6502a

    Joined:
    Feb 16, 2010
    #10
    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.
     
  11. Nape Dog thread starter macrumors newbie

    Joined:
    Sep 26, 2012
    #11
    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?
     
  12. azentropy macrumors 68000

    azentropy

    Joined:
    Jul 19, 2002
    Location:
    Surprise
    #12
    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
     

Share This Page