Quantcast
Channel: How to kill the process using the name of the program instead of PID? - Server Fault
Viewing all articles
Browse latest Browse all 3

How to kill the process using the name of the program instead of PID?

$
0
0

I started my Python program in the background using nohup as mentioned below -

nohup zook.py &

Now I am trying to kill this process so I did the ps command as mentioned below

root@phxdbx1145:/home/david/zook# ps ax | grep zook.py16352 pts/6    S+     0:00 grep --color=auto zook.py

But somehow, everytime its PID getting changed, I don't know why. Whenever I do like this -

kill -9 16352

It always say, No Such Process.

And when I do px command again, I see that PID got changed automatically..

So I am not sure how do I kill this process?

Is there any way I can kill the process with the name somehow?

I tried with

killall zook.py

but it doesn't work for me and I get -

zook.py: no process found

Any other option? Somehow everytime, its PID getting changed.. So I cannot use kill -9 pid

UPDATE:-

This is what I am getting. I did pkill -9 zook.py and then I did ps command as mentioned below and it is shwoing zook.py constantly?

root@dbx1145:/home/david/zook# pkill -9 zook.pyroot@dbx1145:/home/david/zook# ps ax | grep zook.py23870 pts/6    S+     0:00 grep --color=auto zook.pyroot@dbx1145:/home/david/zook# ps ax | grep zook.py23872 pts/6    S+     0:00 grep --color=auto zook.pyroot@dbx1145:/home/david/zook# ps ax | grep zook.py23874 pts/6    S+     0:00 grep --color=auto zook.pyroot@dbx1145:/home/david/zook# ps ax | grep zook.py23876 pts/6    S+     0:00 grep --color=auto zook.py

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images