How do I kill a running background program with PHP? -


i have button in program when pressed, runs line of code.

ps -eo pid,command | grep "test-usb20x" | grep -v grep | awk '{print $1}' 

it gives me correct pid output. example, "3243".

what want kill pid. write

exec("kill -9 3232"); 

but pid changes, how save number variable , use in kill line?

you may write response of first command variable

$pid = exec("ps -eo pid,command | grep \"test-usb20x\" | grep -v grep | awk '{print $1}'"); 

and use variable next command

exec("kill -9 ".$pid); 

Comments