Monday, April 4, 2011

Find Identify and Kill -9

I've decided to start keeping a useful tools blog so that when I can't remember a How To I can return to the blog and find it. Hopefully this will also provide some others with little bits of knowledge here and there.Tonight, my media center was hung, and unresponsive, and because I knew the (partial) name of the process, I could end the hung process with the following:

ps auxww | awk '/YourProcessName/ {print$1}' | xargs kill -9
We are using "ps" to list the processes, awk is then extracting the correct PID (the $1 -first contiguous field in the string.) Last but not least, we are piping that to xargs which allows us to use the found PID for the argument for the kill -9 command.
Simple but useful.
As a side note, @Monkeynova mentioned the
"..foomatic | tac | grep foo" command to replace "..foomatic | tail -n {#} | grep foo" i thought this was pretty swell.




No comments:

Post a Comment