skip to Main Content

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

3

Answers


  1. 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
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search