3

I would like to know how to stop a running process after appending it with &.

For example, I would like to install software foo. Now, assume, foo has many dependancies, it takes an hour to finish. So, I do: yum install foo &. But I would like to stop that on-going process either by making it foreground (the actual premise of my question) so I can interrupt it, or through other methods if necessary.

Ctrl+C does not seem to stop this.

  • Try looking for the PID: pu aux | grep foo – ryekayo Sep 29 '14 at 19:57
7

If the terminal you launched the command from is still open, you can get it back by running fg.

If it is not, identify the process ID by running ps aux | grep yum or just pgrep yum and then use kill PID. Or, if you know you only have one yum instance, run pkill yum.

|improve this answer|||||
  • So, this will kill the entire yum process. Not specific to that foo thread? – robue-a7119895 Sep 29 '14 at 20:07
  • 3
    @CONtext not sure what you mean. The "foo thread" is the yum process. In any case, the fg doesn't kill anything, it just brings a backgrounded job back to the foreground. – terdon Sep 29 '14 at 20:08
3

If you are in the same shell, you can always foreground that process with fg (if your shell supports it) at that point you can perform your Ctrl+C.

As others have mentioned, you can use a wide variety of ps and kill options.

If you want, you can even use top and filter to your username and kill that way.

|improve this answer|||||
2

Try this:

kill -QUIT `pidof yum`

This will stop, terminate this process. It may be required to use some better force than QUIT signal, then try TERM and after that try KILL.

You may be also a little more lazy and just do this:

killall -QUIT yum

This will hit all processes named yum.

|improve this answer|||||
0

The key combination you are looking for isn't

ctrl-c

you use that when you interrupt the process (equivalent to using ctrl-c)

If you ctrl-z instead you would place the job in the background, similar to using & at the end.

However this way you would be able to bring the process back to the foreground by using fg

Alternatively you can look for the pid using pidof as mentioned by Scyld

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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