简单的Nginx日志备份删除
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单的Nginx日志备份删除相关的知识,希望对你有一定的参考价值。
简单的日志备份删除
#!/bin/bash date=$(date +%Y%m%d) [ -d /data/logs/nginx/backup_login_access ] || mkdir /data/logs/nginx/backup_login_access [ -d /data/logs/nginx/backup_service_access ] || mkdir /data/logs/nginx/backup_service_access [ -d /data/logs/nginx/backup_sf_tzyx ] || mkdir /data/logs/nginx/backup_sf_tzyx [ -f /data/logs/nginx/login_access.log ] && mv /data/logs/nginx/login_access.log /data/logs/nginx/backup_login_access/login_access.log.$date [ -f /data/logs/nginx/service_access.log ] && mv /data/logs/nginx/service_access.log /data/logs/nginx/backup_service_access/service_access.log.$date [ -f /data/logs/nginx/sf.tzyx.log ] && mv /data/logs/nginx/sf.tzyx.log /data/logs/nginx/backup_sf_tzyx/sf.tzyx.log.$date [ -f /data/logs/nginx/backup_login_access/login_access.log.$date ] && cd /data/logs/nginx/backup_login_access/ && tar zcf $date.tar.gz login_access.log.$date && rm -f login_access.log.$date [ -f /data/logs/nginx/backup_service_access/service_access.log.$date ] && cd /data/logs/nginx/backup_service_access/ && tar zcf $date.tar.gz service_access.log.$date && rm -f service_access.log.$date [ -f /data/logs/nginx/backup_sf_tzyx/sf.tzyx.log.$date ] && cd /data/logs/nginx/backup_sf_tzyx/ && tar zcf $date.tar.gz sf.tzyx.log.$date && rm -f sf.tzyx.log.$date find /data/logs/nginx/backup_login_access/ -type f -atime +30 -exec rm {} \; find /data/logs/nginx/backup_service_access/ -type f -atime +30 -exec rm {} \; find /data/logs/nginx/backup_sf_tzyx/ -type f -atime +30 -exec rm {} \;
本文出自 “YHT的运维笔记” 博客,请务必保留此出处http://yht1990.blog.51cto.com/9014030/1913042
以上是关于简单的Nginx日志备份删除的主要内容,如果未能解决你的问题,请参考以下文章