Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a script that I want to run everyminute. I understand how to set the timings of it, I've set it as:

*/5 * * * *

My script that I want to execute is at /var/www/html/domain.co.uk/content/inc/download-feed/banter.php

Would I just have my crontab entry as:

*/5 * * * * /var/www/html/domain.co.uk/content/inc/download-feed/banter.php

Or is there something else I need to add to it?

Thanks!

share|improve this question

migrated from stackoverflow.com Jul 9 '10 at 0:15

This question came from our site for professional and enthusiast programmers.

5 Answers 5

up vote 4 down vote accepted

Your cron won't run every minute (instead it will run every five minutes).

Usually, the system does not know what to do with a .php-file. So you have to use the php-interpreter and the file as argument for it:

*/5 * * * * /usr/local/bin/php -f /var/www/html/footy-feed.co.uk/content/inc/download-feed/banter.php

or if you want to run it every minute:

* * * * * /usr/local/bin/php -f /var/www/html/footy-feed.co.uk/content/inc/download-feed/banter.php

Please note: the path "/usr/local/bin/" can be different on your system.

share|improve this answer
    
Thank you very much! And yeah I realised after I typed /5 after the first 'every' by accident :) –  Probocop Jul 8 '10 at 15:06

You'll need the full command, so you are basically missing the php interpreter in the code code you posted. Replace

/var/www/html/domain.co.uk/content/inc/download-feed/banter.php

with

/usr/local/bin/php -f \
     /var/www/html/domain.co.uk/content/inc/download-feed/banter.php

If your php executable live somewhere else, you'll need to adjust /usr/local/bin/php.

share|improve this answer

It depends whether you have the PHP commandline interpreter installed, and whether the code inside your PHP script will just run by itself.

If it's just a piece of PHP you'd normally run from a web browser, it might not work. What's inside it?

share|improve this answer

If you want to process it with PHP, you better run it with:

*/5 * * * * php /var/www/html/domain.co.uk/content/inc/download-feed/banter.php
share|improve this answer

Check if you have executable rights on the script file. Make sure you don't edit the /etc/crontab, but use crontab -e so the config will be saved.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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