tomb
tomb

Reputation: 1827

Can't kill PHP script

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??!

Upvotes: 7

Views: 22968

Answers (3)

ahmed khan
ahmed khan

Reputation: 35

try this command. this will stop file from executing.

pkill -f /my/php/file.php

Upvotes: 0

fedorqui
fedorqui

Reputation: 289495

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]
$

Upvotes: 16

Scott Helme
Scott Helme

Reputation: 4799

You can use 'ps' (process status) to get the ID and then use 'kill' to stop it.

http://linux.about.com/library/cmd/blcmdl_kill.htm

Upvotes: 0

Related Questions