0
서버를 모니터링하는 스크립트가 있는데 서버가 핑이 가능하지 않으면 메일 경고를 보냅니다. 그러나 스크립트를 cron 작업으로 설정하면 ping 명령이 인식되지 않아 mailx 명령을 인식 할 수 없으므로 오류가 발생합니다. 수동으로 실행하면 동일하게 작동합니다.cron 작업에 넣을 때 셸에있는 명령이 인식되지 않습니다.
는 아래 크론 데몬 가능성이 $PATH
변수와 함께 환경을 플러시 스크립트
#!/bin/sh
cd `dirname $0`
serverIPs="192.0.0.40 192.0.0.140"
count=4
##checking the status by pinging the individual ips in serverIps variable
for host in $serverIPs
do
recCount=$(ping -c $count $host | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $recCount -eq 0 ]; then
# 100% failed
echo "Host : $host is down (ping failed) at $(date)" |mailx -s "Server is not responding completely " [email protected]
elif [ $recCount -lt 4 ]
then
echo "Host : $host is not responding well there is loss of packets , please check " |mailx -s "Server is not responding partially " [email protected]
fi
done
cronjob 표현은 무엇입니까? – fedorqui