I'm trying to get my cron jobs to output errors if the cron job fails. I've created a command that will purposefully fail to try and test this, like so:

* * * * * php /var/some/nonexistent/script.php >> cronLog.log 

I don't want to mess with using an MTA since Google Compute Engine blocks all outgoing SMTP requests to port 25, but I can't see anything in cronLog.log. I have the permissions set up correctly, and I can write to cronLog.log no problem when a php script executes successfully. So if the output is being piped successfully to cronLog.log during a successful cron job, why does it just disappear if the command fails? There is nothing in syslog either. Where does my error output go?


You are not capturing stderr which is where the error messages are output. Try

 * * * * * php /var/some/nonexistent/script.php >> cronLog.log 2>&1

the 2>&1 redirects stderr to stdout which is itself redirected to cronLog.log.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.