- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep command does not show up
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 03:13 AM
07-19-2002 03:13 AM
To find out if a specific application is down (or finished) we count the number of processes (with ps -ef | grep xxx).
Sometimes the "grep" does not show up.
cf. the following example :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
N4000:pmurphya:/lprd1/lprd/work $ ps -fu pmurphya | grep lprdet
pmurphya 26576 16765 1 11:58:31 pts/tVb 0:00 grep lprdet
pmurphya 25268 1 70 11:57:10 pts/tcc 0:00 lprdet.exe etbase 0
pmurphya 25371 1 63 11:57:12 pts/tcc 0:00 lprdet.exe etbase 1
pmurphya 25471 1 64 11:57:14 pts/tcc 0:00 lprdet.exe etbase 2
pmurphya 24925 24851 57 11:56:54 pts/tcc 0:00 lprdetcn.exe etctrl
N4000:pmurphya:/lprd1/lprd/work $ ps -fu pmurphya | grep lprdet
pmurphya 25268 1 68 11:57:10 pts/tcc 0:00 lprdet.exe etbase 0
pmurphya 25371 1 63 11:57:12 pts/tcc 0:00 lprdet.exe etbase 1
pmurphya 25471 1 64 11:57:14 pts/tcc 0:00 lprdet.exe etbase 2
pmurphya 24925 24851 59 11:56:54 pts/tcc 0:00 lprdetcn.exe etctrl
N4000:pmurphya:/lprd1/lprd/work $
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I suggested to the application to reduce count to zero ancd change the command with a pipe to rep -v grep.
But still would like to know why this is happening ?
thanks for your contribution,
Jean-Luc
PS : this is running on N4000 / HPUX11.0
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 03:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 03:30 AM
07-19-2002 03:30 AM
Re: grep command does not show up
to my opinion it is some timing "problem" why sometimes the grep itself shows up (It happened to me before) . When you always want to be sure about the correct number of processes do the grep -v like you said yourself:
ps -ef|grep xxx|grep -v grep
BB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 03:41 AM
07-19-2002 03:41 AM
Re: grep command does not show up
command | grep somestring | grep -v grep
for a long time, but with Steven's example, I probably won't be using the
... | grep -v grep
any longer! Good work Steven!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 04:05 AM
07-19-2002 04:05 AM
Re: grep command does not show up
BB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 04:14 AM
07-19-2002 04:14 AM
Re: grep command does not show up
# cat /usr/local/bin/psg
##########################################################################
# 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"
;;
*) echo "Error: Only 1 Argument Allowed";
exit;
;;
esac
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 04:30 AM
07-19-2002 04:30 AM
Re: grep command does not show up
ps -ef | grep -c lprde[t]
and I get my number of process directly !
JL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 04:35 AM
07-19-2002 04:35 AM
Re: grep command does not show up
UNIX95= ps -fu murphya -C lprdet
ps is smart enough to look at the process table and find an exact string match for lprdet (and it uses the basename, not the full pathname). In the above example, you can search for all sh processes with:
UNIX95= ps -fC sh
The UNIX95 variable should only be set temporarily (as in the examples, it is set to null) since exporting UNIX95 will cause several commands and libraries to change behavior. Two additional (and very useful) features are activated with UNIX95: -H (for a list of processes by hierarchy) and -o (which allows for a fully customized appearance.
For example:
UNIX95= ps -efH | more
UNIX95= ps -e -o ruser,vsz=Kbytes -o pid,args=Command-Line
In the second example, the real userID is listed, followed by the program's size but with the label changed to Kbytes, then pid and finally the command line, also with a new label.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2002 04:38 AM
07-19-2002 04:38 AM
Re: grep command does not show up
The snapshot of the processes running missed the time when your 'grep' was active. The technique of:
# ps -ef|grep mything|grep -v grep
...is the classic approach.
A better way to find (or count) a particular running process which avoids the need for multiple 'grep's *and* avoids matches for processes you *don't* want is this:
UNIX95= ps -fC tar
Note that the UNIX95 variable is set only for the duration of the command line. 'ps' is used to find *only* processes with a basename (here, by example) of "tar". See the 'ps' man pages for more details.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2002 06:48 AM
07-22-2002 06:48 AM
Re: grep command does not show up
$sar -v 1
HP-UX fiserv B.11.00 B 9000/800 07/22/02
10:43:55 text-sz ov proc-sz ov inod-sz ov file-sz ov
10:43:56 N/A N/A 459/4020 0 0/5840 0 22431/38890 0
This thread may also prove enlightening:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5c9703bbece8d5118ff40090279cd0f9,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2002 07:06 AM
07-22-2002 07:06 AM
Re: grep command does not show up
More along those lines, ps|grep seems to become much less dangerous if you use:
UNIX95= /usr/bin/ps -e -ocomm | /usr/bin/grep "^sh$" | /usr/bin/wc -l
using the regex items for begin and end of line.