I have the following syntax (which I think is correcT?) but it runs the command every minute!

* */4 * * * /cmd.sh
link|improve this question

6% accept rate
feedback

4 Answers

up vote 1 down vote accepted
0 0,4,8,12,16,20 * * * /cmd.sh

That's probably how I would do it. This will run the job every 4 hours, on the hours of 00:00, 04:00, 08:00 12:00, 16:00, 20:00.

This is just a little more verbose way of writing */4, but it should work the same.

link|improve this answer
Fixed to reflect that mistake. Thanks for the heads up. – phuzion Jul 10 '09 at 16:41
feedback

That will run the job every minute hours evenly divisible by 4. You want:

15 * * * * whatever...

That will run on the 15th minute after every hour. Put your favorite minute number in there.

If you want to run once an hour on hours divisible by 4, do:

15 */4 * * * whatever...
link|improve this answer
1  
You must have misread the question, the command is supposed to run every four hours, not four times per hour. – phuzion Jul 10 '09 at 16:34
His original formatting made it look wrong. Look at my edits. – Evan Anderson Jul 10 '09 at 16:34
Evan is correct. 0 */4 * * * <cmd> would run on the hour every 4th hour. – pauska Jul 21 '09 at 13:45
feedback

Do a crontab -e and then add the following entry

0 */4 * * * path_to_the_script

This will the script every 4 hours.

link|improve this answer
feedback

The problem is the * in the first column

' * */2 * * * /path-to-script '

this translates into run each minute of the hour, but only do it every 2 hours

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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