ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 5.Monitor filesystem usage & delete expire file

5.Monitor filesystem usage & delete expire file

原创 Linux操作系统 作者:tolilong 时间:2016-03-03 22:14:47 0 删除 编辑
[root@oracle6 source]# crontab -l
5,15,25,35,45,55 * * * * /home/mon/source/mon_filesystem_full >> /home/mon/log/mon_filesystem_full.log

[root@oracle6 source]# 
[root@oracle6 source]# 
[root@oracle6 source]# more mon_filesystem_full 
#!/bin/bash
#monitor local filesystem is fully

LOG=/home/mon/data/filesystem_full.txt
FILE=/u01/oracle/product/11.2.0/dbhome_1/dbs
df -P > $LOG

cat $LOG | grep % | while
read LINE
do
  PCT=`echo $LINE | awk '{print $5}'`
  PCTD=`echo $PCT | tr "%" " "`
  if [ $PCTD -gt 64 ]; then
      #echo "$PCTD"
      ls -tr $FILE/arch*dbf | head -10 | while
      read NAME
      do
        #echo "$NAME"
         rm $NAME
      done
      
  fi
done

find $FILE -name "arch*dbf" -mtime +30 -type f -exec rm -rf {} \;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-2029581/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1208693