Filtering exact process name from ps


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Filtering exact process name from ps
# 1  
Old 03-04-2009
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  
Old 03-04-2009
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  
Old 03-05-2009
Try using "ps -ef | grep -w <whatever>"

grep -w searches for the exact "word" you specify.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the exact process using ps aux command?

Please do not post a technical question in the @How to contact....' forum. I have moved this for you. Hello Everyone, Please help me on this, Requirement here is to check whether the process is running using the process id. For the below scenario, I m trying to grep 1750 process id to... (3 Replies)
Discussion started by: Hari A
3 Replies

2. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

3. Shell Programming and Scripting

Grep the exact process in perl script

I am working on one script where I need to grep the exact process in perl script. for e.g. when I run simple grep command on the linux machine it gives me two process mGateway_mvc_q01 and mGateway_mvc_q01_v7 which is not the correct result.I tried to use ( ps -eAf | grep ^mGateway_mvc_q01$) but... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

4. Shell Programming and Scripting

Need help on filtering

Hi experts, I have a file image.csv as below: COMPUTERNAME,23/07/2013,22/07/2013,21/07/2013,20/07/2013,19/07/2013,18/07/2013,17/07/2013 AED03852180,3,3,3,3,3,3,3 AED03852181,3,3,3,3,3,3,1 AED09020382,3,0,3,0,3,3,3 AED09020383,1,3,3,3,2,1,3 AED09020386,3,3,0,3,3,0,3 ... (4 Replies)
Discussion started by: zaq1xsw2
4 Replies

5. Shell Programming and Scripting

echo exact xml tag from an exact file

Im stumped on this one. Id like to echo into a .txt file all names for an xml feed in a huge folder. Can that be done?? Id need to echo <name>This name</name> in client.xml files. $path="/mnt/windows/path" echo 'recording names' cd "$path" for names in $path than Im stuck on... (2 Replies)
Discussion started by: graphicsman
2 Replies

6. Shell Programming and Scripting

Filtering

Hi I am interested in DNS resolving a set of sites and each time the output is different- $ host www.yahoo.com www.yahoo.com is an alias for fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com is an alias for ds-fp3.wg1.b.yahoo.com. ds-fp3.wg1.b.yahoo.com is an alias for... (1 Reply)
Discussion started by: jamie_123
1 Replies

7. AIX

Need help with filtering

Hi!! I have a bit of a task here and filtering/scripting not my strongest. I have to collect info of approx 1100 hdiskpower.so i have appended all the hdisk into a text file and i need it to run the command lscfg -vl to confirm if the drive is symmetrix. here's what i have so far at... (3 Replies)
Discussion started by: vpundit
3 Replies

8. Shell Programming and Scripting

QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed

QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1 CAR2_KEY0 CAR2_KEY1 CAR1_KEY10 CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1 grep... (1 Reply)
Discussion started by: thibodc
1 Replies

9. Programming

C program to make an exact copy of the current process in Ubundu

Hi All, I am new to Linux and i need your for a program which makes the exact copy of the running process. I have got some codes but it only works for the first command and will not work for subsequent commands. Means it works for "ps" but will not work for "ps u". I have changed the code to... (1 Reply)
Discussion started by: subhash007
1 Replies

10. Shell Programming and Scripting

process filtering

;) Hello, i have written a mail previously but now i have written a script to monitor the status of the unix system process,in which i redirect the out put to file now i have a problem filtering the process that are running and stopped. in fact i want to filter for the processes that have... (6 Replies)
Discussion started by: pradeepmacha
6 Replies
Login or Register to Ask a Question