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

What is the difference between specifying "/usr/bin/php" and just using "php" when setting up a PHP script to run in my crontab? I would tend to just use "php" rather than the full path.

30 16 * * *  php /var/www/vhosts/dev_crm/cron/picco.php >> /home/crmpicco/cron-picco.log 2>&1


30 16 * * *  /usr/bin/php /var/www/vhosts/dev_crm/cron/picco.php >> /home/crmpicco/cron-picco.log 2>&1


share|improve this question

Who runs this crontab ?

It may be run by a different user, who does not have /usr/bin in his $PATH, or it may run with a modified environment, equally without /usr/bin in its $PATH.

If in doubt, specify the full path.

share|improve this answer
The crontab is owned and run by the "crmpicco" user. I can confirm that the cron jobs appear to run ok using "php", however how can I check that /usr/bin is in this user's $PATH? – crmpicco Apr 2 '12 at 15:11

The difference is that the first crontab will not work :)

The reason is that the user executing the crontabs don't have its PATH variable populated to limit impact of involuntary mistakes.

You can declare the variable again in front of the command if needed:

30 16 * * *  PATH=/usr/bin/ php /var/www/vhosts/dev_crm/cron/picco.php >> /home/crmpicco/cron-picco.log 2>&1
share|improve this answer
That's more typing than just using the whole path! :P – adaptr Apr 2 '12 at 15:18
@Shadok Both crontabs work, I can confirm that. I assume that means that I have /usr/bin/php "mapped" to php somewhere. – crmpicco Apr 2 '12 at 15:45
FYI "somewhere" is in the PATH variable of the user executing the crontab :) Try to "su user" and then "echo $PATH" and you should the path where your php binary resides in the list. – Shadok May 10 '12 at 16:18

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.