10

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.

1
  • 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, 2011 at 8:05

5 Answers 5

8

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
1
  • From Mavericks or later, an alternative sending yourself a notification 0-59 * * * * osascript -e "display notification \"$(date)\" with title \"Cron test\""
    – wardw
    Mar 8, 2016 at 13:17
10

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.

1
  • On Mt. Lion that location is actually symlinked several times, leading ultimately to: /private/var/at/tabs/, FYI Aug 2, 2013 at 16:54
9

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.

3

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.

3
  • I updated my question. I can edit the cron the way I do it but the cron doesn't run....
    – Radek
    Feb 10, 2011 at 4:29
  • There's no reason joe couldn't be used. The key is that crontab -e is used. Feb 10, 2011 at 5:04
  • joe is the best
    – nkadwa
    Apr 14, 2014 at 18:20
3

If you want to use cron on Mountain Lion you should take a look here: https://coderwall.com/p/ry9jwg or just open terminal and run sudo touch /etc/crontab. After that your jobs in /usr/lib/cron/tabs should be handled by cron.

You must log in to answer this question.

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