码迷,mamicode.com
首页 > 其他好文 > 详细

查找大文件并清空

时间:2019-03-03 15:59:38      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:type   rm -rf   tab   ls -l   data   find   rgs   nohup   cat   

查找大文件并清空
cat /data/application/scripts/autoclean_nohup.out.sh

#!/bin/bash

#定期清理日志文件超过1G--nohup.out
#by licb @20190222
for i in `find ./ -type f -size +1000M -name nohup.out`
do 
cat /dev/null > $i
ls -lh $i
done

[root@netshop-vm2 scripts]# crontab -l
* * * * 7 root /bin/bash /data/application/scripts/autoclean_nohup.out.sh

查找大文件并删除:
find ./ -type f -size +1000M -name nohup.out -exec rm -rf {}\;

find ./ -type f -size +1000M -name nohup.out | xargs ls -l

查找大文件并清空

标签:type   rm -rf   tab   ls -l   data   find   rgs   nohup   cat   

原文地址:https://blog.51cto.com/lcpljc/2357333

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!