Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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>
share|improve this answer
    
Although using cron is still perfectly fine. –  slhck Sep 1 '11 at 20:32
    
Hooray for cron! –  Naftuli Tzvi Kay Sep 1 '11 at 22:14
add comment

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)

share|improve this answer
add comment

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.