tags:

views:

5148

answers:

4

I'm looking to add a crontab entry to execute a script every 30 minutes, on the hour and 30 minutes past the hour or something close. I have the following, but it doesn't seem to run on 0.

*/30 * * * *

What string do I need to use?

The cron is running on OSX.

+13  A: 

Do:

0,30 * * * * your_command

Cheers, V.

vladr
+7  A: 

Try this:

0,30 * * * * your command goes here

According to the official Mac OS X crontab(5) manpage, the / syntax is supported. Thus, to figure out why it wasn't working for you, you'll need to look at the logs for cron. In those logs, you should find a clear failure message.

Note: Mac OS X appears to use Vixie Cron, the same as Linux and the BSDs.

Eddie
I've always used */30 with success but I don't recall an application of mine where it was too critical if it only ran once an hour so I don't think I've ever checked.
Adam Hawes
@Adam Hawes: I've also used */xx with success in the past, but on Linux and other UNIXes. I've not personally tried Mac OSX. The original question didn't say which OS. Some older UNIXes don't support */xx
Eddie
Your answer also worked, but Vlad has fewer rep, so I gave him the points.
Darryl Hein
No credit for extra effort, following up? :)
Eddie
+1  A: 

You mention you are using OS X- I have used cronnix in the past. It's not as geeky as editing it yourself, but it helped me learn what the columns are in a jiffy. Just a thought.

Allyn
This could be helpful otherwise as well.
Darryl Hein
A: 

If your cron job is running on Mac OS X only, you may want to consider using launchd instead. Apple will be using launchd instead of cron going forward.

launchd Wikipedia entry

Getting Started with launchd (official Apple docs)

PCheese