views:

235

answers:

3

Can .php be used in Crontab function on Linux or wil it execute only .CGI scripts?

I'm using Plesk Control panel, I did the settings as per the Crontab doc, but i think it's not executing the php files.

Does any one have the Idea about what more to do with

A: 

You can only make cron run executables. If you wish to run a PHP script, run php -f followed by the script's filename, e.g.:

/usr/local/bin/php -f script.php
Paul Lammertsma
+2  A: 

You can absolutely execute php script from cron.

Like this:

in the crontab:

*/5 * * * * /usr/bin/php5 -q /path/to/script/yourscript.php

Will execute yourscript.php every 5 minutes.

fvu
+4  A: 

To add to the previous answers, yes crontabs can be used to execute php scripts.

You can either have them run through the php interpreter as Paul and fvu suggested, in which case you need to specify the correct path to the php interpereter ( get it in php by using exec('whereis php'); it will print out the path to php on your system ).

The alternative is to simply use wget to fetch the php file via http which in turn executes it.

* * * * * wget http://yoursite.com/yourscript.php
code_burgar