#!/bin/bash nginx_root=/www/server/nginx log_path=/www/wwwlogs yesterday=`date -d "-1 day" +%Y%m%d` mkdir $log_path/$yesterday #移动日志到新位置 cd $log_path for name in `ls *.log` do mv $name $log_path/$yesterday/$name done #删除60天之前的日志 find . -type d -mtime +60 | xargs rm -rf #重新reload nginx $nginx_root/sbin/nginx -s reload