How to track the pid of a background child process(shell script) from a parent script ?
For example :-
$ sleep 10000 &
[1] 4220
where 4220 is the pid of bg process sleep.
Now my requirement is to keep the sleep statement in a shell script(test.ksh) and will be invoking it from another shell script (test2.ksh).
Is there any way to get the pid of test.ksh (child background process) from test2.ksh?
Naanu
February 9, 2005, 10:52am
2
ram...
when u r creating the script test2.ksh, immeditaely after you call test.ksh you could give ID=$$
ID being just another variable, $$ would give the PID of the last process you have run.
ramkumar:
How to track the pid of a background child process(shell script) from a parent script ?
For example :-
$ sleep 10000 &
[1] 4220
where 4220 is the pid of bg process sleep.
Now my requirement is to keep the sleep statement in a shell script(test.ksh) and will be invoking it from another shell script (test2.ksh).
Is there any way to get the pid of test.ksh (child background process) from test2.ksh?
$! is the pid of the most recent process, $$ is the pid of the current process, $PPID is the parent pid. In Korn shell.
Naanu
February 9, 2005, 3:13pm
4
whooopsie jim...thx for correcting...