kill/pkill process by CMD info.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers kill/pkill process by CMD info.
# 1  
Old 07-15-2009
kill/pkill process by CMD info.

I have a process that I'd like to kill. Doing a "ps -fu myusername" gives me:
Code:
UID           PID    PPID  C  STIME TTY     TIME         CMD
myusername    5443   1     0  10:05 ?       00:00:00     /bin/sh    /some/path/crap.sh  -s /yet/another/path/parentProcess
myusername    5593   5443  0  10:05 ?       00:00:00     /usr/java/jdk1.5/jre/bin/java  -somethingToDoWithParent

I'd like to be able to pkill or kill these two processes using a single command. The second process is the child process of the first. Using trial and error, I was able to kill just the parent process using:
Code:
ps -fp $(pgrep -u myusername crap)

I just don't know regular expressions to the point where I can single out this process by "parentProcess" because I think it's an argument and not the actual process name.

If anyone knows the correct command to kill the parent and child, I'd appreciate it. A little explanation of the command would be cool if you have the time. I think I'll be able to figure out any piping.
# 2  
Old 07-15-2009
Try this:

Code:
ps -ef| egrep `ps -ef| grep myusername | grep " 1 " | awk '{ print $2 }'` | awk '{ print $2 }' | xargs kill -9

# 3  
Old 07-15-2009
Good try, but it didn't work. It returned the following:
Code:
egrep: 1043: No such file or directory
egrep: 1065: No such file or directory
usage: kill [ -s signal | -p ] [ -a ] pid ...
       kill -l [ signal ]

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. UNIX and Linux Applications

Unix pkill error; does wily obstruct me killing the process?

have two scripts on Unix; one that starts some processes and the other one for killing a process. At first, I ran the .sh without WILY in it and it worked perfectly; in this way, I could also ran my stopper process. However I need WILY in this so I added it to my script but this time, a message... (1 Reply)
Discussion started by: nerdogan551
1 Replies

3. Linux

Kill a process without using kill command

I want to Kill a process without using kill command as i don't have privileges to kill the process. I know the pid and i am using Linux 2.6.9 OS. (6 Replies)
Discussion started by: sudhamacs
6 Replies

4. Shell Programming and Scripting

Kill a process without using kill command

Sorry, posted the question in other forum. (0 Replies)
Discussion started by: sudhamacs
0 Replies

5. Solaris

Diffirence between Kill and Pkill Command???

Diffirence between Kill and Pkill Command??? (1 Reply)
Discussion started by: udayn
1 Replies

6. Programming

kill(0,-9) don't kill the process

Hi all i have simple c program , when i wish to kill the app im using kill(0,-9) , but it seams this command don't do any thing and the program. just ignore it . what im doing wrong here ? im using HP-UX ia64 Thanks (9 Replies)
Discussion started by: umen
9 Replies

7. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies

8. UNIX for Dummies Questions & Answers

what is the cmd in gdb to know resource info

Hi All, I am running one exe file say xyz and it is executing some 300 files. This xyz hanges when it reach at file no 232. So I checked this particular file by putting in the beginning and it didnt hang at that file but hanaged again at file no 232. So i figure out its not a problem with xyz... (2 Replies)
Discussion started by: gauri
2 Replies

9. Shell Programming and Scripting

Is there any cmd to kill a process including its childs ( or sub processes spawned by

Dear Unix Gurus, Here is my query. If i start a script,it inturn calls many other scripts ..and most of them continue to run in parallel. Suppose,if i want to stop my script for some reason,i need to kill -9 each of the processes running.It becomes clumsy if the sub processes r more. ... (15 Replies)
Discussion started by: gvsreddy_539
15 Replies

10. UNIX for Dummies Questions & Answers

How to use Kill cmd when detect rogue

I'm system administrator and most of our Unix servers in the company host database that are accessed frequently by company employees. One day, one particular Unix server has been reported as being very slow. Upon further investigation using the ps command, we've found a rogue process that is... (8 Replies)
Discussion started by: agui
8 Replies
Login or Register to Ask a Question