xiedengmin 2019-06-27
brew instal cronolog
如果遇到这个错误
执行 sudo chown -Rwhoami:admin /usr/local/sbin
如果没有/usr/local/sbin
这个文件夹先执行 mkdir /usr/local/sbin
mkfifo /usr/local/etc/nginx/access.log.pipe
access_log /usr/local/etc/nginx/access.log.pipe main;
nohup cat /usr/local/etc/nginx/logs/access.log.pipe | nohup /usr/local/sbin/cronolog /usr/local/etc/nginx/logs/access.log.%Y-%m-%d &
nginx start或nginx -s raload
vi delete_nginx_logs.sh
保存内容
LOG_PATH="/usr/local/etc/nginx/logs" save_days=7 find $LOG_PATH -mtime +$save_days -exec rm -rf {} \;
crontab -e
每天0点执行0 0 0 * * sh /usr/local/nginx/delete_nginx_logs.sh