Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 980
user692601 Avatar asked Aug 28 '11 15:08

user692601


2 Answers

ass & at the end of the command.

$D_command="nohup rm -rf videos/'$Mdelete' > /log/deletedfile.log 2>&1 &";
like image 69
Book Of Zeus Avatar answered Oct 15 '22 04:10

Book Of Zeus


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

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

like image 24
Dave Lasley Avatar answered Oct 15 '22 05:10

Dave Lasley