因主機上的硬碟空間不大,需檢查空間大小,小於某個範圍時刪除不要的檔案
#!/bin/sh
# 2005/10/04 fixed by [email protected]
part=”/dev/hda1″
avail=`df -h | grep “$part” | awk ‘{print $4}’ | cut -dM -f1`
aletwpath=/var/log/httpd/aletw/
dwepath=/var/log/httpd/dwe.q4u/
ezenglishpath=/var/log/httpd/ezenglish/
accesslog=access.log
date=`date +%F`
if [ “$avail” -lt “300” ]; then
echo -n “$date , ”
echo -n “space is not enough, ”
echo “and available space is $avail MB”
echo “>_<"
rm $aletwpath$accesslog $dwepath$accesslog $ezenglishpath
touch $aletwpath$accesslog $dwepath$accesslog $ezenglishpath$accesslog
apachectl graceful
else
echo -n "$date , "
echo -n "space is enough, "
echo "and available space is $avail MB"
echo "^_^"
fi
留言