0

I have a PHP script which fetches new headlines from a website. I would like this PHP script to run at the interval of 11 minutes. I have installed crontab in my CentOS 6.5 machine. All my PHP script is contained in /var/www/public/fetch_headlines.php and I am scheduling my crontab using :

*/5 * * * * /var/www/public/news_fetcher.sh

The problem is that to actually enter in news_fetcher.sh to call/run the

2
  • Why do you have a .sh file in your www? What's wrong with just php /var/www/public/news_fetcher.sh ? Commented Aug 17, 2014 at 14:10
  • @BenjaminGruenbaum That was just for a quick example. I don't expose my .sh file to public Commented Aug 17, 2014 at 14:14

1 Answer 1

1

Just do

$ crontab -e
*/5 * * * * YOUR_PHP_PATH /var/www/public/fetch_headlines.php
Sign up to request clarification or add additional context in comments.

2 Comments

I will try this, but if I have php-cli installed, that means I can replace /usr/local/bin/php with it, right?
Thanks. But can you include an example with how to do it in bash? it is it just the same?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.