# 日志切割脚本
脚本如下
注:安装zip命令
代码语言:javascript复制#!/bin/bash
loglist=`ls -l /data/applications/*.log |awk -F '/' '{print $NF}'`
logdate=`date " %Y%m%d"`
for logname in $loglist
do
zip -r /data/applications/logs/"$logname"-"$logdate".zip /data/applications/$logname
echo "" > /data/applications/$logname
done
find /data/applications/logs/* -mtime 60 -exec rm {} ;
# php日志压缩
代码语言:javascript复制#!/bin/bash
LOG_DIR="/opt/apps/get_docker/get_web_php_server/php.log"
DATE=$(date -d "yesterday" "%Y-%m-%d")
cd $LOG_DIR
#压缩php日志
tar -zcf fpm-fcgi-laravel-$DATE.tar.gz fpm-fcgi-laravel-$DATE.log
#删除原始日志文件
rm -rf fpm-fcgi-laravel-$DATE.log