I'm trying to set up a cron job to run a PHP script daily as part of a web-based booking system. It's been running perfectly for several years on a different Apache server using this in the crontab:
0 3 * * * wget -q -O /dev/null http://www.my_other_domain.org.uk/scheduled/my_script.php
I've just installed the script on another Apache server, and it runs correctly when called through the browser. However when I try to use cron, the cron daemon gives the message:
-: warning: setlocale: LC_ALL: cannot change locale (en_GB.utf-8)
-: wget: command not found
When I tried
0 3 * * * /usr/bin/env wget -q -O /dev/null http://www.mydomain.org.uk/scheduled/my_script.php
I got the message:
-: warning: setlocale: LC_ALL: cannot change locale (en_GB.utf-8)
-: /usr/bin/env: No such file or directory
Firstly, am I right in assuming that the setlocale warning is not relevant to the problem?
I've also tried
0 3 * * * /usr/bin/php /var/www/vhosts/mydomain/httpdocs/scheduled/my_script.php
which gives
-: /usr/bin/php: No such file or directory
I also tried putting a shebang as the first line of my script, and getting cron to call it using the full path. The cron daemon reported that there was no such file or directory as /[full_path]/my_script.php .
Trying to use curl was no better.
I haven't got shell access to the server and I've been setting up the cron job through the Plesk control panel. The cron job seems to be running as scheduled. The system administrator did the following for me:
#which php
/usr/bin/php
#which wget
/usr/bin/wget
#which curl
/usr/bin/curl
That seems to confirm that the commands are in the right location.
The above is an abbreviated history - I've lost count of the permutations and combinations I've tried, mostly as a result of reading advice in this and other forums.
Can anyone tell me why the cron job is unable to find the commands and suggest a solution?