开发者

shell_exec does not run in the background, any other solution?

开发者 https://www.devze.com 2023-03-31 13:32 出处:网络
i\'m using php in apache on CentOS. i\'m need to serve users, that they can delete big files by click.

i'm using php in apache on CentOS. i'm need to serve users, that they can delete big files by click. trying to use shell_exec. but its not run in the background. it runs and make the user wait.

my command :

$D_command="rm -rf videos/'$Mdelete'";

shell_开发者_运维知识库exec($D_command);

thanks!


ass & at the end of the command.

$D_command="nohup rm -rf videos/'$Mdelete' > /log/deletedfile.log 2>&1 &";


$PID = shell_exec("nohup $Command 2> /dev/null & echo $!");

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


Try running

rm -rf videos/'$Mdelete' &

using exec. The ampersand indicates to run to the background


Try this:

popen($D_command, 'r')


I know this is quite an old question, but I had the same issue, and this was the only working solution after trying and failing with exec,shell_exec, process_open:

$process = popen("nohup $D_command > /dev/null 2> /dev/null & echo $!", 'r');
$pid = fread($process, 32);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号