简体   繁体   中英

Will cron execute php files or only CGI scripts?

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

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

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.

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

/usr/local/bin/php -f script.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM