Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

nohup &

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
16352 pts/6    S+     0:00 grep --color=auto

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?


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

root@dbx1145:/home/david/zook# pkill -9

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

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

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

root@dbx1145:/home/david/zook# ps ax | grep
23876 pts/6    S+     0:00 grep --color=auto
share|improve this question
Why are you using root? – user25656 Dec 28 '13 at 6:10
I have root access.. These are our machines for our project. – lining Dec 28 '13 at 6:10
up vote 3 down vote accepted

Use killall:

killall <the_process_name>
share|improve this answer
In this case, what it should be? killall – lining Dec 28 '13 at 5:53
@TechGeeky: yes... that should kill the script... as for my experience with killing bash scripts, it works; sometimes I do have to kill other running processes started by the script... – precise Dec 28 '13 at 6:00
It doesn't work for me somehow.. It is saying no such process.. – lining Dec 28 '13 at 6:01
probably the script's already killed... did you try killing the invoked processes ? – precise Dec 28 '13 at 6:03
How do I do that? This is what I am getting when I did ps ax | grep 23248 pts/6 S+ 0:00 grep --color=auto – lining Dec 28 '13 at 6:06

you can use pkill to send kill signal same as kill signal

Eg: pkill firefox 
pkill -9 firefox
share|improve this answer

The pid in your example, the one that keeps changing, is the process ID of your grep trying to find the PID. That means that your ps and grep is not finding the actual process that you are looking for.

Try running your script without the trailing "&", to see what it is doing. Odds are it's failing quietly on you and not actually starting at all.

You can also use the System Monitor tool from the dash to see the full list of processes with process IDs.

share|improve this answer
I am in Ubunut which is not have nice UI.. Everything is command line.. How do I check all the processes ? – lining Dec 28 '13 at 6:11
@TechGeeky, use top command for this. – precise Dec 28 '13 at 6:18
If you can install software, try 'htop'. It is nicer and easier to use (IMHO). – Javier Rivera Dec 30 '13 at 8:12

You can kill with xkill. Just go to the "run" dialog (Alt+F2), type in xkill and your mouse pointer will change to an "x". Point on the application that you want to kill and click, and it'll be killed. Can sometimes be much quicker than loading the System Monitor.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.