Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't kill process in php script on Ubuntu

Tags:

linux

php

i run shell in command line in 1 hours. I want use PHP script to stop it . I known its $pid is 2000 by use getmypid();

I used PHP script as: exec("kill 2000");exec("kill -KILL 2000"); exec("kill -9 2000"); posix_kill(2000,9); but can't kill it.

If in terminal, i simple use ~$ kill 2000 .But can't with php script .

like image 762
meotimdihia Avatar asked Feb 09 '26 16:02

meotimdihia


1 Answers

If you're running PHP with safe mode on you'll have to change safe_mode_exec_dir to include the dirs of the kill binaries, you'll also have to use "su -c" to kill processes not owned as yourself. It also depends on whether exec() is in the list of disabled_functions in php.ini.

like image 161
Echo419 Avatar answered Feb 12 '26 15:02

Echo419