1820879 Members
3809 Online
109628 Solutions
New Discussion юеВ

Process monitor - ps

 
Tan Kian Chye_1
Occasional Contributor

Process monitor - ps

Hi,

I wanted to find out if there is any option under HP-UX that will not display the original process when issue with ps command.

Example.
----------

ps -ef |grep netmon
will only display process that contain netmon and exclude the process started by the "ps -ef |grep netmon"



I know in Solaris, there was this option "-v" under the grep command which will result only the other process that matches the string to appear. However this option is not in the version of HP-UX that I'm using.

Would appreicate that the someone can help me on this. Thank you.


Regard,
Tan Kian Chye
4 REPLIES 4
T G Manikandan
Honored Contributor

Re: Process monitor - ps

ps -ef|grep sn|grep -v grep
Siem Korteweg
Advisor

Re: Process monitor - ps

You can use the following command-line:

ps -ef | grep "[n]etmon"

The command-line of the grep-process is:

grep [n]etmon

This does not match with the regular expression "[n]etmon" and the process will not show up.
Use the quotes to avoid that the filename generation feature of the shell removes the brackets from the command-line when the current directory contains a file netmon.

Siem Korteweg
RAC_1
Honored Contributor

Re: Process monitor - ps

ps -ef|grep [n]etmon.

UNIX95= ps -C netmon
There is no substitute to HARDWORK
Pete Randall
Outstanding Contributor

Re: Process monitor - ps

We use a little script in /usr/local/bin called psg. The psg script contains the following (just like TG's recommendation):


##########################################################################
# psg - Process Search
# Substitute for "ps -ef|grep" command string.
##########################################################################
case $# in
0) echo "Error: Argument Expected";
exit;
;;
1) ps -ef | grep $1 | grep -v "grep"
# 1) UNIX95= ps -fC $1
;;
*) echo "Error: Only 1 Argument Allowed";
exit;
;;
esac


Usage is simply "psg netmon" - much shorter than typing everything else in.


Pete

Pete