vim /root/runscript/cut_nginx_log.sh #!/bin/bash# nginx日誌切割腳本# This script run at 00:00logs_path="/usr/local/nginx/logs/"target_path="/usr/local/nginx ...
vim
/root/runscript/cut_nginx_log
.sh
#!/bin/bash
# nginx日誌切割腳本
# This script run at 00:00
logs_path="/usr/local/nginx/logs/"
target_path="/usr/local/nginx/logs/cut_log/"
mv ${logs_path}beauty.access.log ${target_path}beauty.access.$(date -d "yesterday" +"%Y%m%d").log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
crontab -e
#重啟cron
service crond restart