cutlog.sh 用于切割日志文件,按照小时切割。 #!/bin/bash logdir="/usr/local/nginx/logs" pid=`cat $logdir/nginx.pid` DATE=`date -d "1 hours ago" +%Y%m%d%H` DATE_OLD=`date -d "30 days ago" +%Y%m%d` for i in `ls $logdir/*access.log`; do mv $i $i.$DATE done for i in `ls $logdir/*error.log`; do mv $i $i.$DATE done for i in `ls $logdir/*watchdog.log`; do mv $i $i.$DATE done kill -s USR1 $pid