Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Second proccess question

Status
Not open for further replies.

unixisgood

Technical User
Jan 26, 2005
25
GB
Hi all,
I need a script that will look for some running proccess.Proccess names are have same content as `STARTPROC` but those works for all filesystem ,it will also look that any duplicates of them. STARPROC has to be work only once for every single filesystem.

regarding below proccess list . The script will check that is there any duplicate proccess. For example there are two /a5/script/STARTPROC, it will kill second one which has started after first one. I assume script can catch this from starting time of proccess.


/a1/script/STARTPROC
/a2/script/STARTPROC
/a3/script/STARTPROC
/a4/script/STARTPROC
/a5/script/STARTPROC
/a5/script/STARTPROC
/a6/script/STARTPROC
/a7/script/STARTPROC
/a8/script/STARTPROC
/a9/script/STARTPROC

If is this possible to write a script i will put it into crontab file to run it every 10 minutes.

Thanks for any help.
 
Yes its possible, what have you written so far?

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Hi Mike,
Scripts in filesystems calls some programs. So i should avoid working them more than one proccess. But i shouldn`t kill first created proccess.
 
Does anyone know how to do this. If no is there also possiblity to have only a warning message to session of root user.

For example from ps output
user8 21049 1 0 00:00:01 ? 0:14 /a8/script/STARTPROC
user7 21049 1 0 00:00:01 ? 0:14 /a7/script/STARTPROC
user8 21049 1 0 00:00:01 ? 0:14 /a8/script/STARTPROC
user9 21049 1 0 00:00:01 ? 0:14 /a9/script/STARTPROC

Warning! "/a8/script/STARTPROC" has duplicate process. Kill it immediately.

Thanks for any help
 
will kill second one which has started after first one
your ps command | awk '!/STARTPROC/{next}{if($NF in a)system("kill -9 "$2);a[$NF]}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top