Arthur Khlghatyan
Arthur Khlghatyan

Reputation: 45

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

I want to run cronjob every 2 minutes on specific hour range for example from 10am to 12am

I am trying this:

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

but this doesn't work

Upvotes: 3

Views: 2555

Answers (4)

Samir Selia
Samir Selia

Reputation: 7065

To run cron from 10am to 12am

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

10-23 will run cron from 10am to 11pm. 0 will run cron at 12am

Upvotes: 0

Himanshu Upadhyay
Himanshu Upadhyay

Reputation: 743

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

Upvotes: 1

Vidya Sagar
Vidya Sagar

Reputation: 1719

You should run this

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

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

Upvotes: 1

John
John

Reputation: 348

If you want to run every two minutes from 10am to 12am, you should use 10-12 instead of 10,12 which mean at 10am and at 12am.

And if you want to run this script you should

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

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

- OR -

Specify the php interpreter on run ex :

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

Upvotes: 3

Related Questions