[thelist] system background process php

Bob Meetin bobm at dottedi.biz
Thu Apr 29 08:20:34 CDT 2010

One problem answered and one still brewing.

Bob Meetin wrote:
> I have a script that use convert to resize a file into several various 
> sizes, works fine, but I think of the number of resizes it is taking 
> so long that it causes mysql to time out.  I see errors like: Warning: 
> MySQL server has gone away
> The relevant code looks like:
> <?php
> system("convert  $file -resize 400 '$newfile'");
> ...
> ...
> ?>
> I know you can run PHP in the background, but how would I tell it to 
> run a system command in a php script in the background.
> And as well fix the timeout.  Anything to do with may_packets_allowed?
> -bob
system background process - this works, adding: " >> /tmp/bg.log &", 
redirecting to a tmp page
system("convert  $file -resize 400 '$newfile' >> /tmp/bg.log &");

The bigger problem is that the following convert script itself takes 
around 10 seconds to process on the server whether run as a PHP script 
or run on the command line.  I tested both ways.  However... if I run it 
locally on my average powered Linux PC it runs in just over a second. 

system("convert $file -thumbnail '100x100>' -background white -gravity 
center -extent 100x100 $file >> /tmp/bg.log &");

Is that a CPU, memory problem or what, how do I tell? 

Also, HostGator replied on how to adjust MySQL timeout.


More information about the thelist mailing list