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 am trying to schedule the execution of a .sh script on max OSX 10.8.2

I am using crontab and am getting an odd bug. If i am at the computer and set the task so that it executes in the next few minutes, it starts up as desired, however if i set it for sleeping time (as i wish to), it does not run.

My crontab file looks like this:

1  6  *  *  *  /Users/me/bash/script.sh

Is there some setting i need to flip so that these tasks execute even when the computer has not been interacted with for a time (i presume it's hibernating or some such)?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

cron doesn't run when the computer is off or asleep. Use a LaunchDaemon instead, and use the StartCalendarInterval key to trigger it:

...
<key>ProgramArguments</key>
<array>
    <string>/Users/me/bash/script.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
    <key>Hour</key>
    <integer>6</integer>
    <key>Minute</key>
    <integer>1</integer>
</dict>
...
share|improve this answer
    
+1, thanks. This would be my first LaunchDaemon, could you possibly showmthe entire xml? Would be a massive help to me. Thanks. –  ricardo Mar 13 '13 at 7:12
    
figured it out. thanks. –  ricardo Mar 13 '13 at 10:52
2  
I found this a bit tricky, so i made a tutorial on my blog –  ricardo Mar 14 '13 at 8:37

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.