Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 13622  / 2 Years ago, wed, march 2, 2022, 6:47:19

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.py
16352 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?



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.py

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

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

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

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

More From » python

 Answers
4

Use killall:



killall <the_process_name>

[#27786] Wednesday, March 2, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
soahan

Total Points: 230
Total Questions: 123
Total Answers: 123

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
;