Script not executing from cron

There is a PHP script that works as it should when run from the command line.
I wrote it in the crown:

0 3 * * * php /path/to/script.php param1 param2

According to the cron logs, it starts.
But at the same time, the logs of the script itself are clean and the work that it should do is not performed.

What could be the problem? How can I force cron to save the result (output) of the script somewhere, maybe it gives some kind of error?


Answer 1, authority 100%

In general, cron sends errors via the mail of the user that the task is assigned to. Try to see if you have any local emails? 🙂 And it’s also worth checking that the environment variables are set correctly and it’s better to write the path to php in its entirety.


Answer 2, authority 67%

I usually use this approach for scheduling php scripts:

 ∗ ∗ ∗ ∗ ∗ curl http://sitename/script.php?param1=param1value

Maybe the approach is wrong, but it works.


Answer 3, authority 33%

I’m not sure if Cron has access to environment variables, you should try changing the call to

0 3 * * * /usr/bin/php /path/to/script.php param1 param2

Output to the general log is obtained like this

0 3 * * * /usr/bin/php /path/to/script.php param1 param2 2>&1 | logger -t cronjob

Answer 4, authority 33%

Check the script execution directory, in the cron it is usually equal to / (the root folder), and when run manually (most likely) – to the folder with the script. There may also be differences in the environment of the users from which the launch occurs.