- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- test for running proces.
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
11-19-2001 08:53 AM
11-19-2001 08:53 AM
Hope everyone had a good weeked!Well here is my question. How would I do
ps -ef|grep dba
and test if dba is running do this else do this. I have been playing with it .. and I just cant figure it out.
Thanks
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 08:56 AM
11-19-2001 08:56 AM
SolutionScript skeleton:
===============
#!/sbin/sh
if ps -ef|grep dba|grep -v grep >/dev/null 2>/dev/null
then
# include your commands here
else
# set alert etc.
fi
Put this script in a cron job.
Example:
#!/sbin/sh
if ps -fu oracle|grep ora_|grep -v grep >/dev/null 2>/dev/null
then
echo Oracle background processes are running
else
echo Oracle background processes are not running
fi
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 09:03 AM
11-19-2001 09:03 AM
Re: test for running proces.
At the risk of sounding funny, if you grep for a process by name and you get something returned, then its running. BUT, using your syntax, you should amend it to be:
# ps -ef|grep dba |grep -v "grep dba"
In this fashion you will not be returned the item for which you are grepping.
Remember too, that you would be returned results for any line containing "dba", not just for processes named this!
You would also be returned lines that matched "notdba" for instance which isn't necessarily desired.
You could improve this by doing:
# ps -ef|grep dba$ |grep -v "grep dba$"
...which anchors the search pattern to the end of the line.
You could also express your 'ps' in UNIX95 and look for the basename of the process you wish to match.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 09:06 AM
11-19-2001 09:06 AM
Re: test for running proces.
I was right there but I was going about it a totaly differnt way. A longer and more complicated way. UGG..
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 09:08 AM
11-19-2001 09:08 AM
Re: test for running proces.
Thanks for the extra info.
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 09:10 AM
11-19-2001 09:10 AM
Re: test for running proces.
ps -ef | grep dba | grep -v grep
to
ps -ef | grep [d]ba
If you want a rock solid check on a process, and you know the full name of the process and arguments you can try:
e.g. an oracle pmon for sid PROD
UNIX95= ps -eo args | grep "^ora_pmon_PROD$"
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 09:39 AM
11-19-2001 09:39 AM
Re: test for running proces.
ps -ef|grep dba will find all processes owned by dbarker and processes called fordba3 an bambamdba as well as dba. What you want to search for is the basename of the process as an exact match:
UNIX95= ps -fC dba
And you'll see just the process(es) you are looking for--grep is not necessary (or desirable). The return code is non-zero when there is no match. If there are multiple copies of the same process running, you'll have to count them as in:
COUNT=$( UNIX95= ps -fC dba | wc -l )
COUNT=$((COUNT - 1)) # (don't count header)
if [ $COUNT -gt 1 ]
then
if [ $COUNT -gt 2 ]
then
echo "$COUNT copies are running!"
else
echo "1 copy is running"
fi
else
echo "No copies are running!"
fi
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2001 06:05 AM
11-20-2001 06:05 AM
Re: test for running proces.
I've been doing some playing around with this method, and one thing to bear in mind is that processes like oracle have a habit of changing their argv command lines after they have been started, and although you can see this, the -C option only matches on the original process basename (which is 'oracle' for all oracle processes whether they are server or shadow), so
ps -fC ora_pmon_PROD
returns nothing, but
ps -fC oracle
returns the pmon,smon etc plus the shadow processes.
HTH
Duncan
I am an HPE Employee
