capturing PID and killing the process
Hi, I want to capture PID of a program and kill it using the PID if the program is been executing beyond 5 seconds. Below is my shell script.
./TESTPGM1 > OUT &
# give some time to PROGRAM to execute
# Capture the PID of the program
# If the program is still running, kill it
if ps $PID > /dev/null
echo "$PROGRAM is still running, going to kill PID $PID"
This works perfectly. The problem I'm facing is I have another copy of the same program running under different shell script, and the above code is killing both the process. How do I specifically kill the program which has started under the current running shell script.