1

I need to shut down a Mac every night at 10:00 pm. Does Mac have a scheduler that I should use, or should I defer to cron? I'm a Linux user, this was a question asked to me by a friend. I'd like to be able to insert the command from a terminal like I would in Linux:

crontab -e 

or

(crontab -l >/dev/null 2>/dev/null && (crontab -l && echo "@reboot do-stuff") | crontab -)

What's the best option for doing something from the command line? I'm not exactly too familiar with OSX.

2 Answers 2

5

cron is there for compatibility, but it has been superseded by launchd, which does indeed have the ability to schedule events. You need, in your property list file, a StartCalendarInterval key with a value that is a simple a Hour/Minute pair:

<key>StartCalendarInterval</key>
<dict>
    <key>Hour</key>
    <integer>22</integer>
    <key>Minute</key>
    <integer>00</integer>
</dict>
2
  • Although using cron is still perfectly fine.
    – slhck
    Sep 1, 2011 at 20:32
  • Hooray for cron! Sep 1, 2011 at 22:14
1

pmset is the command line utility for the system preferences energy saver schedule section.

sudo pmset repeat shutdown MTWRFSU 22:00:00

GUI at Apple menu > System Preferences... > Energy Saver > Schedule (button)

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.