I have a script with a curl command in it for php to execute:
/root/notify-down-script.sh
#!/bin/bash
echo "test" > file
curl -d "credentials=foobar" -d "title=$server down" https://notifi.it/api
I can execute from the command line:
/usr/bin/php -r "echo shell_exec(\"/root/notify-down-script.sh test\");"
which works perfectly. When I add to the cron:
* * * * * /usr/bin/php -d safe_mode=Off -r "echo shell_exec(\"/root/notify-down-script.sh test\");"
This does not call the curl (does call the echo
). This is all ran as root. I have tried to catch the output (> /tmp/curl.log) of the curl in the script but nothing happens. I have tried to do the full path of the curl. I am completely lost. What am I doing wrong?
/root/notify-down-script.sh
? Also, check cron logs for errors, or setMAILTO
to an e-mail address to hopefully get an error report.set -x
as the first line, or run withbash -x
) and write the output of that somewhere? That should show how far the execution goes.set|grep ^PHP
. Also, you mention a curl.log but I don't see a reference to it in your code. Can you check the cron log for evidence of it being called?