#!/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
时间: 2024-10-27 07:34:36