The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Getting exact time tdst UNIX for Dummies Questions & Answers 1 08-11-2006 02:58 PM
How to grep the exact name? csaha Shell Programming and Scripting 3 01-31-2006 11:47 AM
Echo-exact matthewwithanm Shell Programming and Scripting 1 08-17-2005 01:38 AM
process filtering pradeepmacha Shell Programming and Scripting 6 04-11-2005 11:18 AM
what is the exact reason ? shamal High Level Programming 2 12-08-2001 01:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-04-2009
sagarparadkar sagarparadkar is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 5
Filtering exact process name from ps

Hi Gurus,

I have two processes running on a Unix box, named say, PRCS1 and PRCS1X.

I want to check whether process PRCS1 is running or not, and depending on that I have to make further decisions while writing a shell script.

I am using: ps -eaf|grep PRCS1|grep -v grep

But the problem is the above command returns the process details of PRCS1X as well, even when the process PRCS1 is not up and running.

I wanted to look-up for the exact process-name PRCS1; nothing more or less. I also tried: ps -eaf|grep "PRCS1"|grep -v grep .... plz forgive my ignorance, I'm not a Guru in Unix.

Can anyone suggest a better way to accomplish this?

Thanks in advance,
Sagar
  #2 (permalink)  
Old 03-04-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,969

Code:
ps aux | egrep 'PRCS1[^X]' | grep -v grep
ps aux | egrep 'PRCS1X' | grep -v grep

Though it may be way more elegant to try to identify them based on pids. Do they generate pid files under /var/run ? You could just check for the existence of files, then the existence of /proc/pid-number where pid-number is the contents of the pid file.
  #3 (permalink)  
Old 03-05-2009
frozentin frozentin is offline
Registered User
  
 

Join Date: May 2008
Location: Vienna, VA + Bombay, India
Posts: 109
Try using "ps -ef | grep -w <whatever>"

grep -w searches for the exact "word" you specify.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0