Stop / kill the process individually


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stop / kill the process individually
# 1  
Old 02-14-2006
Stop / kill the process individually

Hi ,

I have a situation, where I have 10 indivudal processess started by similar instance.I say similar instance because each of them being started as a new thread:
Say I've following unix process running

process1_ADAP
process2_ADAP
process3_ADAP

Current scenario:
Now I have SHUTDOWN script, which grep for process and kills it. Since all the process being started by same isntance(as multiple thread) all of them got killed. Though my intention was no that.


Required scenario:

I would like to kill the process based on their process ids, I wanna know on the runtime how do I collect and store the process id's so that I can kill each of them.
i.e

process1_ADAP has pid 12121
process2_ADAP has pid 13131
process3_ADAP has pid 14141

I wanna store this pid somewhere when I execute the shutdown script, So that only relvant objects are killed.

Appreciate any insight .

Thx
# 2  
Old 02-14-2006
while booting the instance store the pid's of the process
in a file with $$ (PID) and kill
# 3  
Old 02-14-2006
Use ps coupled with grep.

Code:
ps -Ao pid,args | grep 'process[123]_ADAP'

That would give you all pids associated with process*_ADAP.

There is yet another way (less portable). Since all the threads come out of the same process, it would mean the ps listing would show same names but different pids.

Say the process is process_ADAP

Code:
/bin/kill -p process_ADAP

# 4  
Old 02-14-2006
Vino,
thx, what does args stands for in ps -Ao pid,args ?
# 5  
Old 02-14-2006
RTFM.

It translates to the command that is denoted by the respective pid.
# 6  
Old 02-15-2006
look at:

pgrep
pkill
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 for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

3. Shell Programming and Scripting

Help with script to stop a user giving kill command on a server!!

Hi, I am new to shell scripting and want to create a script with the follwoing description: I want to restrict the users from giving a kill command on a unix server. The server have a restricted logins with login id and passwords. I want a script that will find out if a user has given a... (9 Replies)
Discussion started by: shell_scripting
9 Replies

4. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

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

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

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

8. Shell Programming and Scripting

how to start a process and make it sleep for 5 mins and then kill that process

how to start a process and make it sleep for 5 mins and then kill that process (6 Replies)
Discussion started by: shrao
6 Replies

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

10. UNIX for Dummies Questions & Answers

How do I stop or kill Netscape FastTrack Server?

After installing Apache and configuring the httpd.conf file to listen to port 80, I have come to find that there is another server on the Sco box I'm working on. Would someone please tell me how to stop or kill this server. The server is Netscape FastTrack Server. Also, how might I remove all... (2 Replies)
Discussion started by: cstovall
2 Replies
Login or Register to Ask a Question