Killing foo, which I started as foo &.
Hi:
I have a process running in the background, started by me in this way: Code:
$ foo & Code:
[1]+ Stopped OK. But I am almost sure there is a more economical way of killing foo. Which is it? Thanks. |
Look up `pkill` and `killall` - they both are quicker than using `ps` first; alternately, you can do something like:
Code:
kill -9 $(ps blah blah blah | awk '{blah blah}') |
Thanks, most kind GrapefruiTgirl. I referred to a shell built-in command. I must exist. Or a combination of them.
|
Quote:
Code:
$ kill %1 |
Maybe there's something else, but `kill` is what is coming to mind for me.
When you fork a process like that, the PID is returned to you - if you store it (in a variable) then you can later refer to it with `kill` and not need to use `ps`. Look: Code:
sasha@reactor: foo & Code:
sasha@reactor: foo & If there's a larger issue at hand here, and this is just a small part of the larger picture, maybe telling us a bit more about the larger problem will allow someone to offer a specific solution. |
Quote:
As David1357 said, Code:
kill %<job number> Code:
jobs Code:
%<job number> |
Thank you GrapefruiTgirl for your useful explanation.
P.S: I see you've got a US keyboard, like I do. I say it because the exclamation sign is located above the digit one. |
Quote:
|
I see in besides the many virtues of LQ, it has that of provinding me fun. I can't stop laughing at my mistake.
|
Quote:
|
All times are GMT -5. The time now is 02:58 AM. |