scheduling jobs on mac OSX 10.8.2

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

ricardo

Posted 2013-03-12T20:05:40.793

Reputation: 209

Answers

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>
...

Gordon Davisson

Posted 2013-03-12T20:05:40.793

Reputation: 28 538

+1, thanks. This would be my first LaunchDaemon, could you possibly showmthe entire xml? Would be a massive help to me. Thanks. – ricardo – 2013-03-13T07:12:18.727

2

I found this a bit tricky, so i made a tutorial on my blog

– ricardo – 2013-03-14T08:37:50.647