Last active
August 29, 2015 14:15
-
-
Save debojitkakoti/978b2365b8fd1ad80b76 to your computer and use it in GitHub Desktop.
Asterisk zombie killing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
########################################################################### | |
# | |
# clean-up Asterisk zombies | |
# file asterisk_zombie_kill.sh | |
# Description: clean_up all parent dead Asterisk AGI processes, v 1.0 2006/05/10 bb Exp $ | |
# | |
# cron task */30 * * * * root /usr/local/sbin/clean_up.sh | |
# | |
########################################################################### | |
LOG=/var/log/asterisk/cleanUP.log | |
date=`date` | |
t1=`cat /proc/stat | grep btime | awk '{print $2}'` | |
t3=`date +%s` | |
echo "$date New Clean UP " >> $LOG | |
for parent in `ps -ef | grep safe_asterisk | awk '$3 == '1'{print $2}'` | |
do | |
for ppid in ` ps -ef | awk '$3 == '${parent}' { print $2 }' ` | |
do | |
for i in ` ps -ef | awk '$3 == '${ppid}' { print $2 }' ` | |
do | |
t2=`cat /proc/$i/stat| awk '{print $22}'` | |
b=$(($t3-$t1)); | |
c=$(($t2/100)); | |
d=$((($b-$c)/60)); | |
if [ $d -gt 30 ] ; then | |
kill -9 $i | |
echo "$date killing $i" >> $LOG | |
fi | |
done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment