1. 至/root/bin目錄下,新增一shell script的檔案,名為diskspace.sh,內容如下: #!/bin/bash df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) partition=$(echo $output | awk '{ print $2 }' ) if [ $usep -ge 90 ]; then echo "Running out of space "$partition $usep%" on $(hostname) as on $(date)" | mail -s "Alert: Almost out of disk space $usep%" root fi done 2. # chmod 755 diskspace.sh 3. # crontab -e -> 10 5 * * * /root/bin/diskspace.sh 資料來源: http://go-linux.blogspot.com/ http://b2d.phc.edu.tw/modules/tadbook2/view.php?book_sn=23&bdsn=805
文章標籤
全站熱搜
創作者介紹
創作者 付爸爸 的頭像
付爸爸

付爸爸的神奇日記本

付爸爸 發表在 痞客邦 留言(0) 人氣(238)