首页 > 应用开发 > IT综合 > 更改后的监控某个目录的使用情况的shell脚本
#! /sbin/sh -x
bdf |grep /tmp | awk '{print $5}'>PFILE
P=`cat PFILE |wc -c ` //统计该域的字符数数字占1个字符,%占2个字符
if [ $P -eq 4 ]
then
V=`cat PFILE |cut -c1-2`
else
if [ $P -eq 3 ]
then
V=`cat PFILE | cut -c1-1`
else
echo " /tmp already been full
exit
fi
fi
N="90"
if [ $V -gt $N ];then
rm -R /tmp/*
else
echo " /tmp is normal"
fi
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15192459/viewspace-1009413/ ,如需转载,请注明出处,否则将追究法律责任。