1

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)?

1 Answer 1

2

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>
...
2
  • +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, 2013 at 7:12
  • 2
    I found this a bit tricky, so i made a tutorial on my blog
    – ricardo
    Mar 14, 2013 at 8:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .