I have a script that starts a long running task in the background. I would like to capture the process id of that task when it is started. Is there a way to do that?
For example, if I have...
I want to capture the "786".
I tried the following:
I also tried nesting the background start in another script. But neither of the following would even start the background task.
Neither did the following work:
Neither did any of the above options work when redirecting stderr (2>) instead of stdout.
Is this possible?
Code what you mean,
and mean what you code!
But by all means post your code!
Razalas
For example, if I have...
Code:
$ cat delay
runcobol /u/usr/acct/rsrp/DELAY -k -a $1
$ delay 5 &
[1] 786
I want to capture the "786".
I tried the following:
Code:
$ delay 5 & > pid.dat
[1] 1740
$ jobs
[1]+ Running delay 5 &
$ ls -l pid.dat
-rw-rw-r-- 1 razalas users 0 Oct 26 11:23 pid.dat
[1]+ Done delay 5
I also tried nesting the background start in another script. But neither of the following would even start the background task.
Code:
$ cat temp
delay 5 & > pid.dat
$ ./temp
$ jobs
$
Code:
$ cat ./temp
delay 5 &
$ ./temp > pid.dat
$ jobs
$
Neither did the following work:
Code:
$ cat delay
runcobol /u/usr/acct/rsrp/DELAY -k -a $1 &
$ delay 5 > pid.dat
$ jobs
$
Code:
$ cat delay
runcobol /u/usr/acct/rsrp/DELAY -k -a $1 & > pid.dat
$ delay 5
$ jobs
$
Neither did any of the above options work when redirecting stderr (2>) instead of stdout.
Is this possible?
Code what you mean,
and mean what you code!
But by all means post your code!
Razalas