I ran into one problem related to killing a Linux process from my php code. I am running the Scrapy tool from my php code using a function proc_open()in the background.
It works fine, but now I want to kill this process using its process id. For this, I use exec("sudo kill -9 $pid");, where $pidis the identifier of the process that I get from my php code.
The problem is that this process is running on behalf of the apache user. I thought there might be an issue with permissions, so I added the apache user to the sudoers file, like this one apache ALL=(ALL) NOPASSWD:ALL, but I still can't kill him. One way or another, the same kill command works from my putty console.
My code is on an Amazon EC2 instance.
My question is: how can I kill this process identified by pid from php?
source
share