Please see this


Contents

- INDEX
- HP-UX Index
- Solaris
- Linux Index
- Other Unix types
- General Unix
- Unix Networking
- Unix Scripts
- Unix databases

Associated Information

- Unix Scripts Tips

Useful Links

- Bash shell HOWTO
- Bourne Shell Man Page
- C Shell Guide
- Korn Shell Resources

zombie_kill.sh

# # This script will run from cron at midnight, Monday through # Sunday, and kill the parents of zombie processes with a sig # 9. The parent process of a zombie must have a parent process # id of 1. Once a zombie's parent is killed the zombie will make # like a tree and leave. Following conditions must be met before # a sig 9 kill is issued. # # owner cannot be root # tty field must be equal to ?? # program field must be equal to <defunct> # parent process id of zombie's parent must be equal to 1 # # If ANY of the above conditions are not met, then the process # will be considered valid. B=/bin C=cut E=echo G=grep GE=egrep S=sleep LOG=/usr/local/log/zombie_procs_log LOG2=/usr/local/log/zombie_procs_history_log TMP=/tmp/zombie_procs TMP2=/tmp/zombie_parent dat=`date` OS=`uname` if [ "$OS" = "HP-UX" ]; then UNIX95=true export UNIX95 fi export B C E G GE S LOG LOG2 TMP TMP2 dat $B/cp /dev/null $TMP2 $B/ps -eo user,pid,ppid,tty,comm | $B/$G -v root | $B/$G defunct > $TMP $B/cat $TMP | while read UNAME PID PPID TTY CMD do if [ "$TTY" = ?? ] && [ "$CMD" = "<defunct>" ] then $B/ps -fu $UNAME >> $TMP2 PARENT=`$B/ps -fu $UNAME | $B/$G $PPID | $B/$G -v $PID | $B/$C -c21-23` if [ "$PARENT" = " 1 " ] then $B/kill -9 $PPID $B/$S 5 $B/ps -fu $UNAME | $B/$G $PID if [ "$?" -eq 0 ] then $B/$E "Parent process ($PPID) of zombie $PID, belonging to $UNAME, could not be killed on $dat" >> $LOG else $B/$E "Parent process ($PPID) of zombie $PID, belonging to $UNAME, was killed with sig 9 on $dat" >> $LOG fi fi fi done $B/$E " \n******************* $dat *******************\n " >> $LOG2 $B/cat $TMP >> $LOG2 $B/cat $TMP2 >> $LOG2 # # End of zombie_kill script # #### END OF SCRIPT

Copyright 2000 Intronet Computers Ltd
Email: Intronet Computers for enquiries