nginx日志按天切割shell
2017-09-22 11:16
309 查看
#!/bin/bash ############################################## #Author: Liuzhengwei - 1135960569@qq.com #QQ:1135960569 #Last modified: 2017-08-16 16:05 #Filename: nginx_logrotate.sh #Description: ############################################## back_dir=/data/nginx_log year=`date '+%Y'` month=`date '+%m'` if [ ! -d $back_dir/$year ];then mkdir $back_dir/$year if [ ! -d $back_dir/$year/$month ];then mkdir $back_dir/$year/$month fi fi cp $back_dir/access.log $back_dir/$year/$month cp $back_dir/error.log $back_dir/$year/$month cd $back_dir/$year/$month gzip -c access.log > access.log_`(date '+%F')`.gz gzip -c error.log > error.log_`(date '+%F')`.gz find ./ -maxdepth 1 -name "*.log" | xargs rm -f >$back_dir/access.log >$back_dir/error.log任务计划:
59 23 * * * /server/scripts/nginx_logrotate.sh &> /dev/null
相关文章推荐
- tomcat切割日志的shell脚本
- shell切割日志脚本
- shell方式切割tomcat日志
- shell脚本简单切割字符串
- Linux下添加shell脚本使得nginx日志每天定时切割压缩
- shell 切割脚本
- Shell脚本切割tomcat的日志文件
- 运维中的日志切割操作梳理(Logrotate/python/shell脚本实现)
- 常用的shell(备份数据库、备份网站、切割访问日志)
- Linux下添加shell脚本使得nginx日志每天定时切割压缩 推荐
- 运维中的日志切割操作梳理(Logrotate/python/shell脚本实现)
- 【shell脚本】nginx每天自动切割日志脚本
- 每日一shell(八)nginx日志切割
- SHELL awk根据单引号切割
- 字符串切割思路--shell重定向 管道
- shell之使用cut切割文本文件
- 【shell脚本】nginx每天自动切割日志脚本
- 企业shell脚本分析及切割apache日志实战 推荐
- nginx日志切割shell
- 对Shell几个冷知识的总结(IFS,数组,替换,切割,查找)