13

I'm trying to set up an automated svn commit to run semi-hourly under mac os 10.6, but the crontabs i'm adding to cron don't seem to be valid and/or don't seem to even be looked at by cron. For testing i made a simple crontab and script:

Crontab: */2 * * * * /Users/username/crontest

where username is replaced with my system username, thus pointing to my home directory (and yes, those really are tabs between each value - they aren't faithfully reproduced in the code section)

I'm running a crontab -r first, then running crontab .mycrontab that contains the above line. crontab -l spits out the line above, and running ps -A | grep cron shows /usr/sbin/cron running, which I assume is the cron daemon under mac os x. The /Users/username/crontest script is simply appending a line of text to a text file, as such:

echo "hi" >> /Users/username/crontest.txt

What gives? I'm stumped.

2 Answers 2

14

Oops...I was missing the newline character at the end of the cron job. That seems to have fixed it.

1
  • 2
    Just to be clear, I had a similar problem and adding an extra new line to my file when running contrab -e fixed it. Ick. Mar 21, 2010 at 18:50
5

Although the preferred method on OS X for running automated jobs is launchd, cron is still supported. Chances are you have a permissions problems with your script; make sure it has execute permission.

Also, */2 means every two minutes, not semi-hourly. Try setting the minutes field with a list of minutes:

0,30    *   *   *   *   /Users/username/crontest

Works for me on 10.6.

1
  • 1
    Thanks for the tip. Side note: I guess I didn't clarify in my original question that, even though my final cron job was intended to run semi-hourly, my test cron job was in fact intended to run once every two minutes.
    – jtrim
    Jan 6, 2010 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.