How to run a cronjob every 2 minutes in a specific hour range

I want to run a cronjob every 2 minutes in a specific range of hours, for example, from 10am to 12pm

I am trying to do this:

*/2 10,12 * * * /opt/lampp/htdocs/cron/index.php

      

but it doesn't work

+3


source to share


4 answers


If you want to run every two minutes from 10:00 to 12:00, you must use 10-12

instead 10,12

, which means 10:00 and 12:00.

And if you want to run this script, you must

1) Adding php Shebang ( http://www.electrictoolbox.com/php-shebang/ )

2) Make it executable (chmod + x index.php)



- OR -

Specify php interpreter when running ex:

*/2 10-12 * * * php /opt/lampp/htdocs/cron/index.php

      

+2


source


You have to run this

*/2 10-24 * * * /opt/lampp/htdocs/cron/index.php

      



The cron entry will run the job every 2 minutes from 10:00 am to 12:00 pm.

+1


source


*/2 10-24 * * * /opt/lampp/htdocs/cron/index.php

      

+1


source


To run cron from 10:00 am to 12:00 pm

*/2 10-23,0 * * * /opt/lampp/htdocs/cron/index.php

      

10-23 cron will run from 10:00 to 23:00. 0 will run cron at 12 o'clock

0


source







All Articles