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

link|improve this question

feedback

2 Answers

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.

link|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
feedback
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
link|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
feedback

Your Answer

 
or
required, but never shown

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