Nginx的日志分割
#!/bin/bash
# 得到昨天日期
YESTERDAY=`date -d yesterday +%Y%m%d`
#备份昨天日志
cp /software/nginx/logs/access.log /software/nginx/logs/access-$YESTERDAY.log
#清空日志
>/software/nginx/logs/access.log
#清空5天前的日志备份
find /software/nginx/logs -name 'access-*' -mtime +4 -exec rm {} \;
创建计划任务
crontab -e
#定时
#10 0 * * * /software/nginx/logs/auto-del-7-days-ago-log.sh