I have a script that runs on the command line, called by a crontab. In the last five attempts to run this script, it has died partway through an echo statement – the cron output only shows part of the intended echo output, and nothing after that is executed. This is a long-running script, being run through php-cli, which performs file management tasks.
Is there anything that might cause a script to die during an echo statement, without generating any other output, or a way to troubleshoot or catch potential errors during echo?
I am not sure what code I can post that will help, as this is a rather comprehensive script involving a few libraries. The echo statements are fairly simple – echo(‘Checking file…’) might get put in the log as “Che” then no more output.
First, I would enable error-logging. Secondly, since it’s PHP, it may be that you initialize a variable with a function inside the echo function, but the function exits with a fatal error (common with the PHP+I/O operations) and thus the whole script just dies.
Turn on error-logging, see which line causes the headaches.
Without seeing any code this is my best shot.