PHP Script via Cron

software development

#1

I have a php script designed to be run via command line / cron. It runs just fine via the command line. But if I run it via cron I get ‘/bin/sh: php: command not found
’ mailed to me… Do I simply need to find and include the path to PHP in the crontab, or is it more complicated than that?


#2

Just make sure the shebang (#!) line has the full path to PHP (since cron has a very minimal ENV).

which php

/usr/local/bin/php

nate.


#3

[quote]Just make sure the shebang (#!) line has the full path to PHP

[/quote]

or put the full path in the crontab; like:

          • /usr/local/bin/php /path/to/script

#4

Thank you :slight_smile: it worked :smiley: course I forgot to add the -q but that’s easy to fix