PHP CLI Log

Okay, I’m stumped. I don’t do a lot of PHP in a Production environment, let alone in a DEV/TEST environment, so I usually struggle with server setup from time to time as I only do it once every blue moon or two.

My issue is I have a PHP script that takes a LONG time to execute, it could take hours. So it runs via CLI. However, it just quits after 20 minutes or so. No errors, no logs, nothing. I am using the -c argument to tell it what php.ini to use. The php.ini has display_errors turned on, the error_log is defined to a custom location that has write for owner, group and world, I haven’t touched the max memory setting or any execution time (as those weren’t touched on my prior server). I simply copied the php.ini from the prior server to the new one…

So does anyone have any tricks for diagnosing this type of an issue? The only thing I haven’t ruled out is if the script itself is exiting on its own and it isn’t PHP that’s closing the script (simply because I doubt that is the case, but I may have to profile the script to verify).

I’ve done a few searches, but nothing has turned up yet that seems to be the resolution.

Thanks!

There is a maximum for the amount of time a script can run set by the max_execution_time variable in the php.ini file:

http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time
http://php.net/manual/en/function.set-time-limit.php

Those links also indicate that apache has its own maximum execution time, but I’m not familiar with that, since I haven’t yet cause an issue for me.

Yeah, ends up those still don’t apply to CLI (or at least I still haven’t had to change those). I stumbled into the issue (though I still haven’t got the error logging to work for CLI). Ended up the GD extension (which my script required) wasn’t installed. You’d think that result in some sort of error written somewhere, but it didn’t…

Ah well, the script successfully completed after not being run for nearly 15 days, so it took nearly 148 minutes to complete. Should run MUCH faster now since it won’t have that much “new” data to crunch.