开发者

When does a script end without showing the reason?

开发者 https://www.devze.com 2023-02-15 11:08 出处:网络
I am using a script with set_time_limit(60*60*24) to process a big amount of images. But after 1k images or so (1 or 2 minutes), the script s开发者_如何学Ctops without showing any errors in the comman

I am using a script with set_time_limit(60*60*24) to process a big amount of images. But after 1k images or so (1 or 2 minutes), the script s开发者_如何学Ctops without showing any errors in the command line.

I'm also using a logger that writes to a file any error thrown by the script, on shutdown (by using register_shutdown_function). But when this script stops, nothing is written (it should write something, even if no errors are thrown. It works perfect with any other script, on any other situation I ever had).

Apache error_log doesn't show anything either.

Any ideas?

Edit: My enviroment is Centos 5.5, with php 5.3.


It is probably running out of memory.

ini_set('memory_limit', '1024M');

May get you going if you can allocate that much.


Please make sure you're not running in safe mode:

http://php.net/manual/en/features.safe-mode.php


Please note that register_shutdown_function does NOT guaranties that the associated function will be executed everytime. So you should not rely on it.

see http://php.net/register_shutdown_function

To debug the issue check the PHP error log. (which is NOT the apache error log when you're using PHP from the console. check your PHP.ini or ini_get('error_log') to know where it is.)

A solution may be to write a simple wrapper script in bash that executes the script and then does what you want to be executed at the end of the script.

Also note that PHP doesn't count the time spent in external, non-php, activities, like network calls, some libraries functions, image magick, etc. So the time limit you set may actually last much longer than you expect it to.

0

精彩评论

暂无评论...
验证码 换一张
取 消