Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP + shell - Start a process from PHP
    text
    copied!<p>Good day to all.</p> <p>I need to do this: </p> <p>From a computer somewhere in this world I need to access a specific URL and start a process. The only problem is that since the process may last over 5 hours and may return some errors (the process will move over them) PHP commands like exec, shell_exec, etc don't work (don't exactly know why but... all return error and stop execution)... so I tried this:</p> <ul> <li>I made a cron that runs a script</li> <li>use php to write the script file</li> </ul> <p>Everything works fine but I need to return a counter telling me when the process will start so, when I run the php script that edit the shell script I return the hour of the system and start counting till the next full minute (when the script will be executed).</p> <p>Now the only problem is this:</p> <p>The counter SEEMS to work ok... but also the process needs some time to start and that time may vary from 3-4 sec to 1 minute. My question is... can I get sometime of hint at least if not the exact time of when the process will start up and the exact time when it did start?</p> <p>I dunno... like writing in a file and a php script read it for a minute to see when something changed?</p> <p>Ok... I promised I'll add some details:</p> <p>The process is streaming. Live. So this is what I need to do:</p> <p>create a stream give a counter to the user when the stream will start</p> <p>I use ffmpeg for streaming. The start.php have something like: </p> <pre><code> // Create a file called script.sh $string = "ffserver &amp; ffmpeg -i pipe.avi http://localhost:8090/feed1.ffm&amp; echo exit 0 &gt; script.sh&amp; exit 0"; //write string to script.sh //create a file that contains the exact time when the script was run. </code></pre> <p>The cron looks like this:</p> <pre><code> * * * * * /var/www/html/script.sh &gt; /dev/null and some other crons that doesn't matter </code></pre> <p>So I can create a counter that gets the time when the script was run and count till the next minute when the cron will run. The thing is that ffmpeg has some time until it starts (testing codecs, checking file etc.) I need to get that time and include it in timer so when the stream starts the guy that speaks says "Hello". Is not nice for him to do something like "Ok... is this working? Yes? Hello ppl." and is not good for the users to loose the first 3-4 sentences. That's why I need the moment when ffmpeg starts and somehow pass it to a php script. I can manage from there.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload