Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


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

share|improve this question
Have you installed your distro's equivalent of php-cli? You may not have a command-line PHP interpreter. Should be something like sudo apt-get install php5-cli on Ubuntu. – jscott Aug 28 '10 at 17:15
@jscott if that was the case the error would be command not found and not that /bin/sh has not found the php file to execute – Prix Aug 28 '10 at 17:26
jScott that was it, it wasn't installed. Didn't realize it came seperately! – Webnet Aug 28 '10 at 17:54
Could you provide the crontab entry? And perhaps the source of the PHP file you're trying to exec? The message you post sounds like you're trying to walk/search the /var directory. – jscott Aug 28 '10 at 20:14
up vote 0 down vote accepted

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

share|improve this answer

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
share|improve this answer
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. – egorgry Aug 28 '10 at 17:13
@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. – Prix Aug 28 '10 at 17:22

Your Answer


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.