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

while booting the instance store the pid's of the process
in a file with $$ (PID) and kill

Use ps coupled with grep.

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

/bin/kill -p process_ADAP

Vino,
thx, what does args stands for in ps -Ao pid,args ?

RTFM.

It translates to the command that is denoted by the respective pid.

look at:

pgrep
pkill