Hello Perderabo,
#! /usr/bin/ksh
mypid=$$
(sleep 120 ; kill -TERM -$mypid) & ## This will send signal when
## 120 seconds will pass.
sleep 10 ## this is the command which I want to run.
## which will take 10 seconds.
kill -TERM %1
exit 0
When this is executed, you will still see that one background process against sleep still be running even after completion of the shell job and that process will be sleep and that sleep command will be active for 120 seconds. Is there any way, we can terminate/kill this job after finishing the sleep 10 job.
In short, I would like to kill the sleep process, if the command which I want to run (in our example it is sleep 10) is taking < 120 seconds.
Do you understand what I want to say.
Thank for your help.
Sanjay