본문 바로가기

스크립트

[스크립트] dns2.sh

반응형

dns2.sh 스크립트

dns2.sh editor

vim /usr/sbin/dns.sh
#!/bin/sh
 
while true
do
 
NAMED="/usr/sbin/named"
NAMED2="/usr/sbin/named2"
NAMEDSTART1="/usr/sbin/named
NAMEDSTART2="/usr/sbin/named2 -u named -c /etc/named2.conf"
CHK=`ps -ef |grep $NAMED |  grep -v named2 | grep -v grep`
CHK2=`ps -ef |grep $NAMED2 | grep -v grep`
 
if test -z "$CHK"
then
date >> /var/named/log/dns.txt
ps -ef | grep named >> /var/named/log/dns.txt
$NAMEDSTART1
echo "Restarting NAMED1 Process." >> /var/named/log/dns.txt
ps -ef | grep named >> /var/named/log/dns.txt
netstat -na | grep 53 >> /var/named/log/dns.txt
fi
 
if test -z "$CHK2"
then
date >> /var/named2/log/dns.txt
ps -ef | grep named >> /var/named2/log/dns.txt
$NAMEDSTART2
echo "Restarting NAMED2 Process." >> /var/named2/log/dns.txt
ps -ef | grep named >> /var/named2/log/dns.txt
netstat -na | grep 54 >> /var/named2/log/dns.txt
fi
 
 
sleep 3
done
chmod +x /usr/sbin/dns.sh

 

728x90
반응형