Jump to content

Executing multiple scripts in the background...


Jabop

Recommended Posts

I have a script written that will convert video upon upload. I made it do it in the background to save the user the wait of the conversion process as well. I have two execs(); being called, both of them are crucial parts in the video converting process. However, since the initial conversion process is sent to the background, the second one gets called immediately.

 

Example:

 

exec(do video converting >& /dev/null & disown);
exec(update metadata >& /dev/null & disown);

 

This presents a problem: the metadata update execution gets done immediately after the previous process is put into the background, so it tries getting the data from the video that hasn't converted completely just yet.

 

My question is, is there a way I can delay the second execution by a certain amount of time? I tried sleep(x), but that hangs the http request til the sleep is finished as well.

 

 

 

 

Thanks everyone

Link to comment
Share on other sites

I tried sleep(x), but that hangs the http request til the sleep is finished as well.

I don't think you can avoid that, but you can finish the page.

after "</html>" and before sleep(x); add

ob_flush();
flush();

Link to comment
Share on other sites

I understand. do something like this:

make a 3rd script:

#!/bin/bash
do video converting >& /dev/null;
update metadata >& /dev/null

then just call the 3rd script, assigning variables as needed in that one.

 

How can I call phpvars into the bash script?

 

I tried sleep(x), but that hangs the http request til the sleep is finished as well.

I don't think you can avoid that, but you can finish the page.

after "</html>" and before sleep(x); add

ob_flush();
flush();

 

I may give this a shot

Link to comment
Share on other sites

jonsjava - I'm not familiar with passing any variables to bash actually. There are many that need to be given to the query.

 

So would the 3rd script look something like

 

#!/bin/bash
do video converting -i $InputFile -o $OutputFile >& /dev/null;
update -i $FinalFile metadata >& /dev/null

 

Etc... ? Forgive me for the monotony.

Link to comment
Share on other sites

So there is one script now:

do video converting -i $InputFile -o $OutputFile >& /dev/null;
update -i $FinalFile metadata >& /dev/null

 

I call the script by exec('whatever.sh'.$InputFile,$OutputFile,$Foo);?

 

I know that is failcode, but I don't know how it'd be passed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.