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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check running processes from an inputfile

Status
Not open for further replies.

sivhaga

IS-IT--Management
Jun 3, 2008
25
I have got an inputfile having processes names.
The file called atp.text has got two fields and looks like:

createcase createaa
createcase createbb
createcase createcc

This file has got a 85 records and we started all the processes with the following command:
{
cmd="nohup " $1 " ATP $ENVIRONMENT -sectionname " $2

system(cmd)
}

The above code starts all the processes from the above file.The challenge that im facing now is when one or more processes have stopped, how do i check if they have stopped and how to start it. How do i compare from the system and the one from my input file which one has stopped.If it has stopped i have to start it but if it is still running i have to skip it

Which code can i use on Unix or Awk. Pls pls pls I have spend 3 weeks and not winning.

Thanks in advance

 
Well, when you read in the atp file, add the count of processes that are expected to another array, e.g. refcount[$2]=$3.

Then when you are matching running processes, instead of just assigning an empty value to running, use it as a counter, e.g. running[$12]++.

And finally, when you process the for loop at the end you can compare this counter to the expected count of processes, and display the appropriate message.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top