#!/bin/bash #切割nginx的日志,然后定期删除 source /etc/profile log_path=/usr/local/nginx/logs d=`date +%Y-%m-%d` d90=`date -d‘5 day ago‘ +%Y-%m-%d` ##5天前 cd ${log_path} && cp access.log $log_path/backuplog/accesslog$d.log gzip -f $log_path/backuplog/accesslog$d.log echo > access.log rm -rf $log_path/backuplog/accesslog${d90}.log.gz
最后写个crontab
59 23 * * * /bin/sh /data/shell/accesslog.sh
本文出自 “渐行渐远” 博客,请务必保留此出处http://825536458.blog.51cto.com/4417836/1908476
原文地址:http://825536458.blog.51cto.com/4417836/1908476