Note: this question is not about how to edit cron tab but how to make cron work


  1. I edited my cron using env EDITOR=joe crontab -e
  2. I entered 1 * * * * echo 'test' > /Users/radek/Backup/rationalvmware/test.txt and it does nothing although the cron is set up correctly. Checked via Cronnix and viewed the cron in /var/cron/tabs. Editing crontab using Cronnix gives me the same results.

If I run echo 'test' > /Users/radek/Backup/rationalvmware/test.txt manually it creates a files as expected so I assume that the command I provide to cron is correct one.

Is there anything special I have to do to make cron work on OSX? How can I check it the the cron is running.

What's the equivalent of /var/log/messages on OSX? I can see in messages on SuSE that cron works.

link|improve this question

1  
As an aside: note that cron runs in a different environment than your own test command would. For example: you might often need absolute paths. – Arjan Feb 10 '11 at 8:05
feedback

4 Answers

up vote 1 down vote accepted

I doubt you waited until 1 minute past the hour for your test. To run every minute:

0-59 * * * * echo 'test' > /Users/radek/Backup/rationalvmware/test.txt
link|improve this answer
feedback

The cron utility is launched by launchd when it sees the existence of /etc/crontab or files in /usr/lib/cron/tabs. There should be no need to start it manually. (See the man pages.)

To see logs of OS X, you can use Console Utility.

link|improve this answer
feedback

Two other ways are to use:

*/1 * * * * echo 'test' > /Users/radek/Backup/rationalvmware/test.txt

or

* * * * * echo 'test' > /Users/radek/Backup/rationalvmware/test.txt

These both run every minute.

link|improve this answer
feedback

First, you need to set your $EDITOR variable to something reasonable, since what you did set it to something you don't want. Set it like this:

EDITOR=joe

You can change joe to another text editor, such as nanoor vim.

Then, you'll want to edit your crontab, which is done like so:

crontab -e

Then you'll put in the text for cron to use.

link|improve this answer
I updated my question. I can edit the cron the way I do it but the cron doesn't run.... – Radek Feb 10 '11 at 4:29
There's no reason joe couldn't be used. The key is that crontab -e is used. – Dennis Williamson Feb 10 '11 at 5:04
feedback

Your Answer

 
or
required, but never shown

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