Kabir
Kabir

Reputation: 2156

Setting up the crontab on amazon ec2 cloud (Linux server)

I need to run a php file on every 2 hours, so i am using this command

* */2 * * * /usr/bin/php /var/www/html/sports/webservices/rss-insert.php

i am also using this

* */2 * * * php /var/www/html/sports/webservices/rss-insert.php

But both are not working. can anyone help me.

Thanks

Upvotes: 1

Views: 949

Answers (2)

Jyotir Bhandari
Jyotir Bhandari

Reputation: 109

This works for me definitely work for you.

0 0-23/2 * * * php /var/www/html/sports/webservices/rss-insert.php

Upvotes: 0

ianjs
ianjs

Reputation: 827

The crontab you have made will run every minute of every second hour rather than every two hours.

In order to get it to run every two hours you need something like this:

5 */2 * * * /usr/bin/php /var/www/html/sports/webservices/rss-insert.php

which will run it 5 minutes after every second hour e.g 2:05, 4:05...

This is assuming your script is able to run. Try running the command portion from the cron by hand at the command line and make sure it does what you want.

Upvotes: 2

Related Questions