Very easy and powerful way to use ps command on linux servers.
We all know that “ps” command is very useful to capture the running processes on linux live servers. Majority time we are using the ps command along with grep command to find a specific process.
Here we had tried to write a script to save your very important time, while executing “ps” command.
With this below script you did not require to type “ps” command every time with grep, and even you will get the same result.
Just try to create below file in “/usr/local/bin/psgrep” and then paste it with the following lines in it.
# ! /bin/bash
#######Above line is called “she bang” in shell scripting ########
# psgrep – below is the string which will search for a process by pattern.
ps –ef | grep –v grep | grep $1
Now just save this file. And then change the permissions of this file, make it for world executable.
Now whenever you want to use “ps” command then you have just need to type ‘psgrep httpd’ to grep the process httpd.
This is really cool tip of “ps” command. This will save yout too much time when you are working on linux servers.
We had tested this on Redhat linux, fedora linux and ubuntu linux. You can also try on your linux desktop. Hope this will save your important time and your
work will become faster. This is linux’s power. 🙂