I want to convert an uploaded PDF file to JPG images and zip these images after convert process finishes. I use the ImageMagick
library's convert
command for PDF to JPG conversion.
To accomplish this, I use the &&
operand like this:
convert /tmp/asdassa_1395994117.pdf -density 200 /tmp/files/asdassa_1395994117.pdf.jpg && zip -r /tmp/files/files.zip /tmp/files/* &
This command works just fine except one thing: It runs on the foreground so the server doesn't respond until it finishes.
If I use either one of these commands by adding &
at the end of the command, it runs on the background and I can get the response asap. But when using together, it doesn't.
Is there something that I'm missing? Might it be about the command type? Because testing the &&
and &
operands with simple commands like sleep
and mkdir
works on the background as I expect to be, for example this command:
sleep 10 && mkdir bla &
Goes to the background and creates the bla dir after 10 seconds.
P.S. My server runs on Amazon Linux AMI 2013.03
Edit: It turned out that the problem wasn't about the OS but the exec()
function of PHP. Please check my answer to see how I worked it out.