Harpal
Harpal

Reputation: 12587

Kill a python process

I wrote a python script but accidentally put an infinite while loop in my script.

How do I kill the process? I've tried ctrl+c but with no success.

Are there any other option to try?

I'm on Mac Os X 10.7.2 with python 2.7

Upvotes: 17

Views: 68130

Answers (4)

Ranvijay sachan
Ranvijay sachan

Reputation: 2444

try this.

pkill -9 python

or

ps -ef|grep python
kill -9 <pid>

or

lsof -i :port

or 
sudo kill $(sudo lsof -t -i:8000)

Upvotes: 25

onetwopunch
onetwopunch

Reputation: 3329

Open Activity monitor, go to the Processes tab, and highlight python.exe and quit it by clicking Quit.

Upvotes: 1

tdenniston
tdenniston

Reputation: 3519

ps a to get the PID of your process. kill -9 <pid> to send it the unblockable SIGKILL signal.

Note that I only have a Linux box in front of me to test, so the OS X commands may be slightly different.

Upvotes: 25

wim
wim

Reputation: 362647

Try Ctrl+\ to send a SIGQUIT.

Upvotes: 33

Related Questions