Hi,
I am new this forum. I request you peoples help in understanding and finding some solution to my problem.
Here it goes:
I need to perform this set of actions by writing a shell script. I need to read a config file for the bunch of processes to execute.
I need to fecth the pid of the executed process everytime i spawn it and put it to the background processing and continue to spawn other
process read from config file. Finally after spawing all process and put them for execution in background I need to wait for 10 minutes
and then kill them all based on their pid's gracefully. and restart the same process.
can you please let me know how to do this?
I will be very thankful if you can help me on this.
Example config file:
PARAM1_MIN=20
PARAM1_MAX=40
PARAM2_MIN=20
PARAM2_MAX=30
PARAM3_MIN=1
PARAM3_MIN=100
....
...
...
CMD="lbench -a"" ( here i need to substitute all paremeters average of min and max )
And I need to spawn a process of CMD in background and get its pid for future to kill it gracefully
I will have some n number of such commands to be spawn.
example:- CMD1="lbench -a (PARAM1_MIN+PARAM1_MAX)/2 -z (PARAM2_MIN+PARAM2_MAX)/2 -t (PARAM3_MIN+PARAM3_MAX)/2"
I need to run such CMD's in background gettheir PID's and kill them gracefully after sleeping for 10 minutes.
Well $$ will give you the script's PID, a ptree (Solaris ?) of that PID will list its parent and child processes, ps -ef | grep " <PID> " would list list all the direct child processes and the script itself in order to determine which PIDs you wish to kill.
Yes using $$ I am able to get the pid of the current running process. Inside the script I have set of processes to be executed.
When I used '$!' to get the pid of the processes. I dont see any value in that.
could you please let me know how to collect the pid's of the executed commands or processes into a array. so dat using the index I can traverse through the pid list