Handy *nix Commands, Part 1: Finding Processes
On countless occasions, I have needed to find the PID of a process, in order to watch it or, more often, to kill it. For quite some time, I would simply run "ps ax | grep" followed by part of the process' name that I wanted to find. (Side note: it helps to also add " | grep -v grep" to this to eliminate the grep itself from the results.)
This works, but it is slow to use. I had to read through the results of ps to get the PID, when that is often all I wanted. One could use awk to grab just the PID column, but there are faster solutions:
In both cases, you just pass the command the name (or part of it) of the process you want to find, and you get all matches. You can use pkill, or pipe to kill, to initiate the demise of the process once you find it.
This works, but it is slow to use. I had to read through the results of ps to get the PID, when that is often all I wanted. One could use awk to grab just the PID column, but there are faster solutions:
In both cases, you just pass the command the name (or part of it) of the process you want to find, and you get all matches. You can use pkill, or pipe to kill, to initiate the demise of the process once you find it.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home