Notice: Undefined index: key in /home/worker/data/www/liuzimu-blogs/usr/plugins/MysqlRun/Plugin.php on line 138 shell 清理脚本 - liuzimu ‘ blog
  • Home
  • Notice: Undefined index: key in /home/worker/data/www/liuzimu-blogs/usr/plugins/MysqlRun/Plugin.php on line 138
  • archives
  • Github

  • Notice: Undefined index: key in /home/worker/data/www/liuzimu-blogs/usr/plugins/MysqlRun/Plugin.php on line 138
  • Notice: Undefined index: key in /home/worker/data/www/liuzimu-blogs/usr/plugins/MysqlRun/Plugin.php on line 138

shell 清理脚本

nginx 日志清理

#删除日志后,记得
nginx -s reload

清理docker日志

#!/bin/sh 

echo "======== start clean docker containers logs ========"  

logs=$(find /var/lib/docker/containers/ -name *-json.log)  

for log in $logs  
        do  
                echo "clean logs : $log"  
                tail -n 200000 $log > $log  
        done  

echo "======== end clean docker containers logs ========"

递归清理文件夹下的所有.log日志

#/bin/bash
function getfiles(){
  for file in `ls $1`
  do
    if [ -d $1"/"$file ]
    then
      clearPath=$1"/"$file
      echo "开始清理目录:"$clearPath

      find $clearPath -mtime +3 -name "*.log"

      find $clearPath -mtime +3 -name "*.log" -exec rm -f {} \;
    fi
  done
}

getfiles /home/worker/data/www

本文链接:

http://zimu.devorz.com/archives/21/
1 + 3 =
快来做第一个评论的人吧~