Yes, pkill
. If your script is named myPythonScript.py
, you can run:
pkill -f myPythonScript.py
Note that that command will kill all running instances of myPythonScript.py
. It will also kill any other process whose full commandline includes the string myPythonScript.py
so, for example, it would kill your editor if you had launched it with something like emacs myPythonScript.py
.
To be sure you kill only the running script, you can try matching the command more specifically:
pkill -f "/python.*myPythonScript.py"
That will only kill processes matching /python
, 0 or more characters and the name of the script. Since the script will look like this in the list of processes:
terdon 20559 0.0 0.0 22768 7404 pts/4 S+ 18:18 0:00 /bin/python /home/chapplec/scripts/myPythonScript.py
That should kill only running instances of the script.