0

I have done a website using php which basically does task of recording videos from a IP camera in the background. So here is what i do I login into my account and then hit a record button which calls the backend ajax script which executes a program and records videos successfully and stops as soon as i refresh or reload the page. Now what i want is the video recording script should continue in the background to record videos even after the user logout. how can i accomplish this task . Can anyone give me a simple idea to do this?

Have a look at my video recording code using ajax. click here Video recording is done by start.php which contains main logic.

Community
  • 1
  • 1
Roger Mendes
  • 57
  • 1
  • 10

1 Answers1

0

Your PHP file starts another program right?

I assume in php you use something like popen or exec. Here is how you have it done without PHP waiting for it to finish: http://php.net/manual/en/function.exec.php

function execInBackground($cmd) {
    if (substr(php_uname(), 0, 7) == "Windows"){
        pclose(popen("start /B ". $cmd, "r")); 
    }
    else {
        exec($cmd . " > /dev/null &");  
    }
} 

Not sure what you mean by user logging out, if you mean log out from the website then it should not be a problem because PHP is no longer concerned with the recording program.

HMR
  • 37,593
  • 24
  • 91
  • 160
  • yes i do mean log out from website i want the process to execute in the background . how can i use the above function to run the file continuous ? – Roger Mendes Mar 05 '13 at 07:14
  • It is how you call the video capturing program. $cmd is the command you are using. This code goes in your php page. – HMR Mar 05 '13 at 07:30