Can't kill PHP script

19,165

To kill the process you can do the following:

  • Get the PID with ps -ef
  • kill it with kill -9 <pid>

A nice reference: When should I use kill -9?

Just for fun, an example:

$ sleep 100 &
[1] 4156
$ ps -ef | grep slee[p]
me    4156  3501  0 10:34 pts/5    00:00:00 sleep 100
$ kill 4156
[1]+  Terminated              sleep 100
$ ps -ef | grep slee[p]
$
Share:
19,165
tomb
Author by

tomb

Visual stuff maker/programmer, demoscener, lurker. He/him.

Updated on September 20, 2022

Comments

  • tomb
    tomb over 1 year

    I am developing some PHP scripts on a Namecheap shared server. I accidentally made a loop which seems to go on indefinitely (or for a very long time), so now I am trying to kill it using SSH.

    I have viewed a list of running processes with top, found the misbehaving PHP script, and tried to kill it with kill. However, after I kill it with this command, when I try using the ps, it is still running!

    The result of the ps:

       PID TTY      STAT   TIME COMMAND
    819520 ?        S      0:00 /usr/bin/php /my/php/file.php
    

    I have tried killing the process over and over, but it just won't die!

    The SSH is limited, so I can't use commands like killall. What do I do??!

  • Jason
    Jason over 8 years
    Thank you for the reference link! In my case, I used "ps ux" and just plain kill <PID>. I didn't have any problems.