解决mail: command not found
解决mail: command not found
今天使用脚本来监控系统状态,为了把每天系统状态记录下来并发到邮箱里,我写了个脚本来实现,但在发邮件的过程中出现了mail: command not found.
系统:centos 5.9
脚本内容:
#!/bin/bash dug=$(df -h | grep "/$" | awk '{print $4}' | awk -F% '{print $1}') cug=$(expr 100 - $(mpstat | tail -1 | awk '{print $10}' | awk -F. '{print $1}')) mug=$(expr $(free | grep "cache:" | awk '{print $3}') \* 100 / $(free | grep "Mem:" | awk '{print $2}')) alog="/root/alert.txt" AMAIL="root@localhost.localdomain" if [ $dug -gt 3 ] then echo "Disk usage:$dug%" >> $alog fi if [ $cug -gt 2 ] then echo "cpu usage:$cug%" >> $alog fi if [ $mug -gt 2 ] then echo "Memory usage:$mug%" >> $alog fi if [ -f $alog ] then cat $alog | mail -s "Host Alert" $AMAIL rm -fr $alog fi
解决办法:
yum -y install mailx sysstat
评论: