Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

* */4 * * * /cmd.sh
share|improve this question
4  
0 */4 * * * /cmd.sh - your problem was the * in the first column. –  Suman Feb 28 '13 at 21:48

4 Answers 4

up vote 23 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.

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

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...
share|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

Do a crontab -e and then add the following entry

0 */4 * * * path_to_the_script

This will the script every 4 hours.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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