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

I want to have my script run every 23'th around (so 11 PM) and between 7-19 every 2 hours. In directadmin I use this:

23,7-19/2 however, in crontab it will be ran every minute. What syntax should I use? My complete line:

* 23,7-19/2 * * * /usr/local/bin/php script.php

share|improve this question

2 Answers 2

up vote 0 down vote accepted

The key point with CRON is that it will run when ever the current time matches the pattern specified. So with all those *s, a lot of times will match.

I can't make sense of what exact times you are trying to describe though, so I can't give you the exact config that would work.

share|improve this answer
    
Thanks. I'm using 0 23,7-19/2 * * * /usr/local/bin/php script.php now. I was using (as minutes) a '*', so every minute matched. Stupid me. Didn't saw the * at all... –  Devator Oct 5 '11 at 7:53
0 7,9,11,13,15,17,19 23 * * /usr/local/bin/php script.php

will run the script exactly at every second full hour on every 23th between 7h and 19h. But I am not sure anymore this is what you want to do.

Another interpretation would be that you want to run it between 7h and 19h and at 23h, but daily. Then change it to

0 7,9,11,13,15,17,19,23 * * * /usr/local/bin/php script.php

The six fields of the crontab are

min hour dayofmonth month dayofweek  command
share|improve this answer
    
Thanks. I'm using 0 23,7-19/2 * * * /usr/local/bin/php script.php now. I was using (as minutes) a '*', so every minute matched. Stupid me. Thanks anyway! –  Devator Oct 5 '11 at 7:52

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.