Hi ,
I am trying to kill a process thru php.
<?php
$pid=system("pidof myprocess");
echo "\n$pid";
exec("echo my pid is $pid", $out);
echo "restart process $pid";
exec("kill -6 $pid",$out);
var_dump($out);
?>
I am grabbing the process id successfully in $pid, and passing it to exec, but that doesn't work. I think its a permission thing, as all the above works, except the kill statement, which I believe its SELinux that gives me permission denial to execute the command via php.
I am on the sudoer list- how can I do this. I don't want a complicated function - Its just to allow my secretary to restart some batch jobs via a simple web page. She wouldn't know what a linux terminal is if her life depended on it.
Cheers,
C.
Kill process in Php - sudo
Moderator: General Moderators
Re: Kill process in Php - sudo
Kill a process which is not responding:
killall -9 processname
The numeric argument specifies a signal to send to the process. In this case, the command sends signal 9 to the process, which is SIGKILL, as opposed to the default SIGTERM.
killall -9 processname
The numeric argument specifies a signal to send to the process. In this case, the command sends signal 9 to the process, which is SIGKILL, as opposed to the default SIGTERM.
Re: Kill process in Php - sudo
You can only kill processes that are owned by the user executing the kill command. If not you need to use sudo. Try this first, before any attempt to mess with SELinux policies.
Code: Select all
`sudo kill -s 6 $pid`There are 10 types of people in this world, those who understand binary and those who don't