My solution to zombie process - Hope this helps
Posted in 1995
The following is the solution that I've used to kill zombie SQLTURBO processes on a RISC/6000
(AIX 3.2) & Informix Online (5.?).
The shell script was executed periodically by a cron process as root. As I
mentioned before in a previous e-mail process, part of the script is run as
root and the other as informix. The reasoning is root is needed to kill the
processes (root has privileges to kill anybody's process) bu informix is
needed to examine the database and invoke informix related commands.
I can't remember the exact syntax for the cron process but the command to invoke it was:
root's crontab
----------------
* 0 6,10,11,12,13,15,16,17,19 * * 1,2,3,4,5 su - informix -c "zkill.frm" >> zombies.log
For our users, terminals were dropped after 2 hours of idlesness. Most "zombies" occurred
between 11am - 1:30pm (lunch time & people forgot to logoff) and 3:00pm - 6:00 (meetings &
leaving for the day), Monday-Friday. So, I had cron run the process during those times as well
as first thing in the morning before most people logged on the day. For those unfamiliar with
cron, the 5 fields are:
Minute 1-59
Hour 0-23
Day of month 1-31
Month 1-12
Day of week 0-6 where 0=Sunday
where a comma is used between multiple values, hyphen is used for a range and an asterisk to
indicate all possible values. Incidentally, I had a cron process that printed zombies.log weekly and
nulled it out to begin over again.
Also, I use a userid of "dba_owner" which represents the owner of all the tables. I hope this isn't
too crypic and proves to be useful to someone. It probably needs some tweaking as I wasn't able
to find the actual crontab syntax.
Bournce shell script: zkill.infrm
-------------------------------------
date
#
# Set input field separator (IFS) to a newline
IFS='
'
#
# Set default values for variables
#
INFORMIXDIR="/home/informix"ZOMBIES="NO"
ZOMBIE_IDS=""
#
# Read all SQL processes, determine if there are any zombies which are denoted by
# the dash ("-") in the process
for SQLPROC in `ps -eF user,pid,tty,comm`; do
IFS= ' ' # Set IFS to space & TAB
set $SQLPROC
ZOMBIE_USER=$1 # Get userid
PID=$2
PTS=$3
COMM=$4
if [ "$COMM" = "sqlturbo" ] && [ "$PTS" = "-" ] \\
&& [ "$ZOMBIE_USER" != "dba_owner" ] ; then
ZOMBIES="YES"
# Build the list of zombie processes
ZOMBIE_IDS="${ZOMBIE_IDS} ${PID} ${ZOMBIE_USER} ${COMM}"
fi
done
# If there are zombies, begin elimination processes
if [ "$ZOMBIES" = "YES" ] ; then
# Will be echoed to zombie.log
echo "These zombies exist for informix..." $ZOMBIE_IDS
IFS=' '
# Sorry, but I don't remember when tbconfig(1&2) were set to. We had 2 instances
# of our database.
for TBCONFIG in tbconfig tbconfig2; do
export TBCONFIG
IFS='
' # set IFS to newline
#
# Check the interface status for each zombie with the Online engine to prevent
# cancelling a process that maybe in a critical section of the database
#
for TBLINE in `$INFORMIXDIR/bin/tbstat -u`; do
IFS=' ' # Set IFS to space
set $TBLINE
for PID in $ZOMBIE_IDS; do
# Verify the Process ID & ensure that no flags are set
# by Informix stating a critical part of the db
if [ "$3" = $PID -a "$2" = "-------" ] ; then
#- Kill the connection to the Engine
$INFORMIXDIR/bin/tbmode - z $PID 2> /dev/null
# Find & Kill fglgo process
PROC=`ps - fp $PID | grep $PID`
set $PROC
PPID=$3
# su back to root (-c to skip prompting for password)
# & kill the process
su - root -c "kill -9 $PPID"
# Log nameto file specified in crontab
echo "Killed by informix: " $1 $PPID
# Send auto-generated mail to remind user to logoff
# before leaving terminal idle.
mail $1 < /u/dba_owner/bin/zombie.mail
break;
fi
done
done
else
echo "No sqlturbo zombies found by informix....."
fi
#
# End of zkill.infrm
zombie.mail
--------------------
Your terminal was idle for more than 2 hours. As a result, the system automatically drops your
connection. Please remember to logoff when you leave your terminal.
This message is automatically generated so please do not respond via e-mail.