Nginx Log文件自动切割
cut_nginx_log.sh:
logs_path="/usr/local/nginx/logs/"
mv ${logs_path}access.log ${logs_path}access_$(date -d "yesterday" +%Y%m%d).log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
然后将cut_nginx_log.sh加入到crontab中,定时在每天0点执行。
cut_nginx_log.sh:
logs_path="/usr/local/nginx/logs/"
mv ${logs_path}access.log ${logs_path}access_$(date -d "yesterday" +%Y%m%d).log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
然后将cut_nginx_log.sh加入到crontab中,定时在每天0点执行。