pgrep is a useful tool that can allow one to grep a process by name and return it’s id. From the pgrep manpage it will “look up or signal processes based on name and other attributes”. pgrep comes in very handy when scripting something that i will need to kill a particular type of process.
For example, if i wanted to kill a mysql process
[root@computer ~]# pgrep mysql 7321 7343
Now that we have the process id’s of the mysql process from pgrep we can kill each of them using the kill command.
[root@computer ~]# kill 7321 [root@computer ~]# kill 7343
Using this command makes it easy to single out processes to eliminate without all of the extra output ps can provide.
Leave a Reply
You must be logged in to post a comment.