Hi friends,
i am working in ksh88. i am running the follwing wapper script in background to run two jobs parallely((eg nohup wrapper.ksh &)::
wrapper.ksh
########################
#!/bin/ksh
nohup ./pii_insert.ksh /nsing83/p2/test &
nohup ./pii_update.ksh nsing83/p2/test &
wait
echo "the wrapper script is done"
######################
->the wrapper scripts is running fine if it is running for few hours. but when it is required to run for the more than 10 hours , then it is not waiting for the two sub process to complete and it is getting killed before that.(i.e it is not printing the last echo line)
please help.
[/COLOR][/SIZE][/FONT]
try it this way.
capture the process id of sub process and keep checking for completion in a loop after some interval.
wrapper.ksh
########################
#!/bin/ksh
nohup ./pii_insert.ksh /nsing83/p2/test 2>&1 &
# Capture pid of process and write into file
echo $! > subprcs_pid
nohup ./pii_update.ksh nsing83/p2/test 2>&1 &
# Capture pid of process and write into file
echo $! >> subprcs_pid
# Wait in a loop (5 minutes sleeps) while the pids are still active.
if [[ `cat subprcs_pid |wc -l` -gt 0 ]]; then
PIDS_ACTIVE=1
while [ $PIDS_ACTIVE -ne 0 ]
do
sleep 300
for PID in `cat subprcs_pid`
do
# ps -p returns 2 rows if the pids are active else one row
ACT_PID=`ps -p $PID|wc -l|tr -s " "`
if [ $ACT_PID -eq 2 ]; then
PIDS_ACTIVE=1
break
else
PIDS_ACTIVE=0
fi
done
done
fi
echo "the wrapper script is done"
######################
1 Like