Monday, February 28, 2011

Re: how to redirect and let the server do some lengthy job in the background?

On Feb 28, 8:14 am, Zaky Katalan-Ezra <procsh...@gmail.com> wrote:
> On a Linux machine  create a bash file like this
> -----
> #!/bin/sh
>
> ffmpeg -i $1 -r $2 $3 &
>
> -----
> The ampersand at the end tell the bash to run in the background.
> the $n is parameters.
>
> From php call it like  this:
> $command = mybashpath.sh inputfile.mpg 24 outputfile.flv;
> *exec* ( $command );

That's not going to work.

If the calling process (php http request) finishes before the child
("ffmpeg ... &") then your child process will die immediately also.
For your example you'd want

exec('nohup ffmpeg ... &');

however, IMO you're better off using a real queue system, if for no
other reason that it makes pushing logic into background processes so
much easier in general (sending emails, processing files, reindexing
data etc. etc.)

AD

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: