Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kill a python process

Tags:

python

macos

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

like image 397
Harpal Avatar asked Nov 09 '11 14:11

Harpal


People also ask

How do you kill a Python process code?

A process can be killed by calling the Process. terminate() function. The call will only terminate the target process, not child processes. The method is called on the multiprocessing.

How do I kill a Python process in Windows?

You can also create a batch file called kill. bat with this command and place it in a folder that is seen as an eviromental variable so that you just can write the command kill to eliminate all the running threads of the python running scripts.

How do I kill all Python processes in terminal?

Type the command sudo pkill python to kill all the Python processes running, regardless of the user who started the process.


2 Answers

Try Ctrl+\ to send a SIGQUIT.

like image 171
wim Avatar answered Oct 23 '22 12:10

wim


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.

like image 32
tdenniston Avatar answered Oct 23 '22 12:10

tdenniston