nginx 簡單定時切割及刪除歷史日誌

#!/bin/bash

logs_path="/usr/local/nginx/logs"

mv ${logs_path}/book.log ${logs_path}/book-`date --date="last day" +%Y%m%d`.log
mv ${logs_path}/book.error.log ${logs_path}/book.error-`date --date="last day" +%Y%m%d`.log

kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`

find ${logs_path} -name "book*.log" -mtime +30 -delete

//配置定時任務html

crontab -e
0 0 * * * /usr/local/nginx/html/book/console/cut_nginx_log_daily.sh 2>&1
相關文章
相關標籤/搜索