Executing a shell script in background with php

前端 未结 2 1700
[愿得一人]
[愿得一人] 2021-02-06 10:26

I need to execute a shell script. The catch is I want to do this

$Command = \"nohup cvlc input --sout \'#transcode {vcodec=h264,acodec=mp3,samplerate=44100}:std{         


        
2条回答
  •  礼貌的吻别
    2021-02-06 10:47

    $str = shell_exec($Command.' 2>&1 > out.log');
    

    You need to redirect the output of the command.

    If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

    http://php.net/manual/en/function.exec.php

提交回复
热议问题