Saturday, January 29, 2011

Can't execute PHP via cron

My cron commands are "php -q PATH-TO-FILE"

I'm getting "/bin/sh: php: not found" errors. What path should I be using to execute PHP, or how can I find out?

update

PHP5-cli is now installed. Now I'm getting /bin/sh: /var/lib/php5: Permission denied when all of these are run as root

  • Because your crontab does now know what the ENVIROMENT is so you must tell the PHP path.

    /usr/bin/php -q PATH-TO-FILE
    

    If the file is not on the above path which is the most common path in most default installation you can run the bellow command to find where it is:

    whereis php
    
    egorgry : to find out the path of php on your server you can type whereis php. but it is most likely /usr/bin/php just like Prix suggested.
    Prix : @egorgry true... i will edit with it but just in case the user does not have a default installation so he is aware of how to find it.
    From Prix
  • The command-line interpreter of PHP can be a separate package. I know it is in Debian. On Ubuntu the following command should install the requisite tools:

    sudo apt-get install php5-cli

    From jscott

0 comments:

Post a Comment