Question

I am very new to php, if anyone can help me by telling what the difference is between these two cron commands, I would be very thankful:

/usr/local/bin/php -q /home/delightl/public_html/myfolder/run.php

and

php -q /home/delightl/public_html/myfolder/run.php

I am totally confused.. On my GoDaddy server, the second command worked, but in another resellerclub server both worked. What is difference between these commands?

Was it helpful?

Solution

The only difference is that one specifies the full path to the PHP binary, and the other doesn't.

PHP can be installed in different locations. That's why it works on one server, and not the other.

OTHER TIPS

There is a pro and a con to using either of these:

/usr/local/bin/php -q /home/delightl/public_html/myfolder/run.php

Pro: Specifies the full path to the PHP binary, does not depend on the user's $PATH environment variable to correctly include the path to where PHP is installed.
Con: The location of the PHP binary can vary from system to system.

php -q /home/delightl/public_html/myfolder/run.php

Pro: Usually does not require alteration from system to system.
Con: Will frequently not work as many PHP packages will not add PHP to the $PATH of the cron user, or the environment in which cron is run is left blank or not populated because it is not an interactive session.

IMHO the best solution is to always use the full path. If you are not certain what the path is run which php via shell which will tell you the full path to the binary, so long as it is in your $PATH.

See: http://en.wikipedia.org/wiki/PATH_%28variable%29

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top