Process Management | ||
---|---|---|
Prev |
Let's face it: the only time we use kill to send a signal is to kill a process. And that's why it's called kill.
I usually have netscape crashes, so I have a small shell script that does:
#!/bin/sh ps xu | grep netscape | grep -v grep | awk '{ print $2 }' | xargs kill -9 |
prints all my processes
takes only the lines containing 'netscape"
discards the line about 'grep netscape'
selects the second column of ps xu ( the one showing the PID)
xargs builds the command "kill -9 PID" by taking everyword coming from the pipe and launching kill -9 on it. If I had several PIDs coming down the pipe, xargs would launch a kill -9 on each of those PIDs.