Schedule a Mac to sleep, just one time

Is it possible to schedule a Mac to sleep just one time? I know I can set a schedule for it, but I want to have control over it.

So occasionally I'll go to bed but leave a file transferring, and I want the Mac to sleep about an hour from now. So how would I go about doing that, without setting a long-term schedule?


The pmset terminal command should do what you want. The following will put the computer to sleep at 23:45:00 on December 2, 2014. The command must be run from an administrator account though:

sudo pmset schedule sleep "12/02/14 23:45:00"

The MM/DD/YY date format cannot be changed; so, if you are used to a different format, use caution.

If you do this on a regular basis, you can write a function and save it to your ~/.profile:

# Schedule sleep in X minutes, use like: sleep-in 60
function sleep-in() {
  local minutes=$1
  local datetime=`date -v+${minutes}M +"%m/%d/%y %H:%M:%S"`
  sudo pmset schedule sleep "$datetime"
}

By default there is no way of doing that with the options you have in the system preferences.

enter image description here

But, you could do it from command line with a simple command:

sleep 10; osascript -e 'tell application "System Events" to sleep'
  • sleep 10 pause the execution of the following command for 10 seconds. If you want minutes or hours you must change 10 with number of seconds you want.
  • osascript -e 'tell application "System Events" to sleep' put the computer to sleep.

For power control of your Mac from your iPhone on a local network, I have used Off Remote which can also schedule within the next 24 hours a system action (Shutdown, Lock, Restart, Log off, Sleep) and is only $3 in the iOS store but requires installation of an additional helper app on your Mac to receive the instructions from the iPhone app.

Another answer here suggested using Power Manager software which costs $50, but I would suggest the $36 Keyboard Maestro software which is a bit less intuitive than Power Manager but has greater flexibility beyond power management. In searching for the ability to schedule my Mac to sleep, I remembered that I have this utility and was able to quickly drag and drop the macro components in KM to create a script that paused for a set period of time and then put my Mac to sleep:

keyboard maestro script to put Mac to sleep after 2 hours

…there is also an action within Keyboard Maestro to also schedule macros (to put Mac to sleep, shutdown, restart, etc.) to be triggered at designated times:

keyboard maestro trigger for macro based upon time and day(s) of week

Keyboard Maestro is cheaper and much more robust for developing macros that can enhance the use of your Mac, but there is a bit more of a learning curve than the Power Manager application.


All the above answers work, but if you want to do this regularly, I recommend the Power Manager software, which allows you to set custom sleep times, both for one time and recurring events very easily (far more easily than using Terminal commands, in my opinion). The software is relatively expensive ($50), but there is a free 30 day trial with all features. You can also control Power Manager from your iPhone, which is nice if you are away from your computer but want to set it to sleep or shut down.