Inside a long running php process on a debian system, there is an exec
statement that gets called thousands of times (~100000 times). The script does batch processing on images, 20 at a time. Part of this, it uses exec
to call the imagemagick library's convert
command line utility to extent an image.
The issue is that, after running for few hours and processing few tens of thousands of images, the program starts to fall through a while loop.. because exec can't fork a process, and the entire process quickly comes to a end with a lot of the images still in the processing queue.
I've looked around for the possible causes of exec can't fork warning, and can cross out these possibilities:
- permissions - I have
777 -R
given to folders related to the process. - resource unavailability - Network, Memory, CPU usage, Disk Free Space all seem fine.
It might be due to php's child process limit php -r "echo exec('ulimit -u');"
getting consumed completely, but I am not sure.
So, how do I run a command line utility, wait for it to complete, make sure every resource the utility used is freed?
exec()
calls? – Mr Shunz Jun 12 '14 at 9:35convert -gravity center -extent 200x200
. I've looked at imagemagick docs and couldn't figure how to do this.. there is the extentImage, setGravity and setImageExtent. I guess I have to use both setGravity and setImageExtent together. – Prasanth Jun 12 '14 at 9:58