gringomike
Technical User
Hi all,
I'm looking for a script that will report on rogue processes.
I have 10 jobs (job1, job2 job3 etc) that login and logout together at various times of the day. The problem is that they don't always logout as expected and this causes problems for future processing.
These jobs are started by running a script (start_jobs.ksh) and they write a lock file to a directory (/processing/jobs/lock) to prevent multiple instances of the same job from running at the same time.
I need to be able to run a script that will report which of these jobs are still running when they shouldn't be and which jobs have left a lock file behind when they shouldn't have.
I have the following written so far but I still think I'm some way from finding the final solution.
LOGGED_IN=`ptree $JOB |grep start_jobs.ksh`
JOB_INFO=`ps -ef |grep JOB |awk '{print $2, $11}'`
#JOB_NAME=`ps -ef |grep JOB |awk '{print $11}'`
#JOB_ID=`ps -ef |grep JOB | awk '{print $2}'`
for JOB in `ls -1 /processing/jobs/lock`
do
echo "JOB_INFO"
if [ $LOGGED_IN ]
then
echo "$JOB is logged in as expected"
else
echo "$JOB is a rogue process and should be terminated. Please remove the lock file also"
fi
done
If any of this doesn't make sense then i'll try to explain things some more!
Thanks for your help in advance!
GM
I'm looking for a script that will report on rogue processes.
I have 10 jobs (job1, job2 job3 etc) that login and logout together at various times of the day. The problem is that they don't always logout as expected and this causes problems for future processing.
These jobs are started by running a script (start_jobs.ksh) and they write a lock file to a directory (/processing/jobs/lock) to prevent multiple instances of the same job from running at the same time.
I need to be able to run a script that will report which of these jobs are still running when they shouldn't be and which jobs have left a lock file behind when they shouldn't have.
I have the following written so far but I still think I'm some way from finding the final solution.
LOGGED_IN=`ptree $JOB |grep start_jobs.ksh`
JOB_INFO=`ps -ef |grep JOB |awk '{print $2, $11}'`
#JOB_NAME=`ps -ef |grep JOB |awk '{print $11}'`
#JOB_ID=`ps -ef |grep JOB | awk '{print $2}'`
for JOB in `ls -1 /processing/jobs/lock`
do
echo "JOB_INFO"
if [ $LOGGED_IN ]
then
echo "$JOB is logged in as expected"
else
echo "$JOB is a rogue process and should be terminated. Please remove the lock file also"
fi
done
If any of this doesn't make sense then i'll try to explain things some more!
Thanks for your help in advance!
GM