Grep a specific process name


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep a specific process name
# 1  
Old 04-10-2015
Hammer & Screwdriver Grep a specific process name

Hello,
I want to grep a specific process named "TEST" in AIX but not only is it showing what I want but also listing others that have the similar name. How can I only list "TEST"? I've tried using options grep -w with no change and grep -o isn't supported in my environment.

Please advise.

Output I'm getting:
HTML Code:
# ps -ef | grep 'SYS.TLOCK.* TEST'
root  6354813        1   0 02:17:01      -  0:00 phantom SYS.TLOCK.BLANKET.RELEASE TEST-23
root 21546512        1   0 02:17:01      -  0:00 phantom SYS.TLOCK.BLANKET.RELEASE TEST
root 57813454        1   0 02:17:01      -  0:00 phantom SYS.TLOCK.BLANKET.RELEASE TEST-RED
# 2  
Old 04-10-2015
Did you consider 'SYS.TLOCK.* TEST$' as the pattern? The $ sign indicates the line end.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 04-10-2015
Thanks RudiC! That worked perfectly!
# 4  
Old 04-11-2015
Hello again,
I have a follow up question on the same topic.

My script asks the user to enter the current working directory for a "PEND.PAH" process. It will then display the working directory and the running process. My problem is how can I get it to only display "TEST" and not TESTDEMO? I tried inputing the $ sign but it didn't work. Any help is greatly appreciated.

Code:
printf "Enter Account name: "
read A

        ps -e -o pid,args | grep "PEND.PAH" | grep -v grep | while read pid command
        do
          ln=`procwdx $pid`
          echo "$ln" | grep -q "${A}" && echo "$ln" && ps -ef | grep $pid | grep -v grep | sed -e 's/^[ \t]*//'
        done
        echo


OUTPUT:
Code:
54831582:       /home/TESTDEMO/
root 54831582        1   0 02:16:23      -  0:00 phantom PEND.PAH

72218431:       /home/TEST/
root 72218431        1   0 04:32:40      -  0:00 phantom PEND.PAH

# 5  
Old 04-11-2015
Not clear. Where does TESTEDMO show up?
# 6  
Old 04-12-2015
Assuming you entered TEST into A, you can precise the filter with
Code:
echo "$ln" | grep -q "/${A}/" ...

This User Gave Thanks to MadeInGermany For This Post:
# 7  
Old 04-14-2015
Sorry for not replying sooner. Your suggestion worked perfectly! thank you so much!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Watchdog for a specific process trigger another process

Hi, I am willing to build a script that does a "ps-ef" or "top" on a specific process, and if it finds it running to start another process. Any suggestions to do this in a optimized way? Thanks! (2 Replies)
Discussion started by: liviusbr
2 Replies

2. Shell Programming and Scripting

Help with kill a specific process after certain running time

Hi, Do anybody experience to write a bash script in order to kill a specific process (java) after certain time of running? eg. java java.jar task_run.txt I will run a java program (java.jar) which will run a long list of process (task_run.txt) one by one. I plan to terminate the java... (5 Replies)
Discussion started by: perl_beginner
5 Replies

3. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

4. Shell Programming and Scripting

ulimit -n for specific process

Hello all, I need to set the ulimit -n for a specific java process we are running. Can someone please verify my syntax. ulimit -n 10000 java com.Company.Application.Application.CustomJavaProcess & (2 Replies)
Discussion started by: jeffs42885
2 Replies

5. Shell Programming and Scripting

How to check for a specific process running or not in Unix

I have used ps -ef | grep <process name> to see if the process is still running or not. But, not being able to find anything in particular. Any clue on this... (4 Replies)
Discussion started by: Haimanti
4 Replies

6. Shell Programming and Scripting

Script to kill the specific process

Hi I have the process to kill regulary, but the PSID is dymatic change and not sure how to kill the specific process ID Check the tradekast_rvd is running , if such process, kill the els process id ps -e f |grep tradekast_rvd ps -ef |grep els then I kill els process id ... (2 Replies)
Discussion started by: linux_user
2 Replies

7. Shell Programming and Scripting

grep the process id and kill all the filtered process

Hi I want to write a shell script which can find the process id's of all the process and kill them eg: ps ax | grep rv_ 3015 ? S 0:00 /home/vivek/Desktop/rv_server 3020 ? S 0:00 /home/vivek/Desktop/rv_gps 3022 ? S 0:00 /home/vivek/Desktop/rv_show ... (7 Replies)
Discussion started by: vivek_naragund
7 Replies

8. UNIX for Dummies Questions & Answers

top output for a specific process to a file

Hi, I have the following script, and it is driving me nuts. It just hangs, I've tried all kinds of tricks, but it won't work. I know it can, it is pretty straight forward. It hangs when it tries to output $X Any help appreciated! #!/bin/bash set -o xtrace command="top -b"... (10 Replies)
Discussion started by: Bloke
10 Replies

9. UNIX for Dummies Questions & Answers

getting unix stats for a specific process

Hi, We are trying to run reports to determine what percentage of the physical cpu's are being used by Informix ( oninit ) processes on an Aix5.3 box. Is there any way to do that ? Sar just captures percentages but not by process name Topas allows us to see some of the processes, but even those... (1 Reply)
Discussion started by: fwellers
1 Replies

10. Shell Programming and Scripting

Killing specific process

Hello, I need to create a process that will kill a specific process if it's running. Let's just say the process is called win, actually called something else. It could be running multiple times on the machine and I would want to kill them all. Below is the code I have written so far, and it... (6 Replies)
Discussion started by: benefactr
6 Replies
Login or Register to Ask a Question