logrotate服務 用法
一般logrotate 都是nginx 自帶日誌管理模塊
var /etc/logrotate.d/linuxaccount
編輯linuxaccount
/alidata/server/nginx/logs/access.log{ 日誌文件存放位置
su root www 指向用戶(不寫會報錯)
notifempty 爲空不執行切割
daily 以天切割
rotate 30 保留30天內的
dateext 以日期格式命名文件
missingok 文件找不到的話也不報錯,直接跳過
create 0640 root root 創建權限文件
size 500M 文件大於多少也會切割
olddir /alidata/server/nginx/logs/access/ 新文件存貯地方
sharedscripts
postrotate
/bin/kill -HUP `cat /alidata/server/nginx/logs/nginx.pid 2> /dev/null` 2> /dev/null || true 告訴nginx 繼續在老文件寫入
endscript
}
手動 執行方式命令: /usr/sbin/logrotate -fv /etc/logrotate.d/linuxaccount
利用crontab -e :
4 * * * /usr/sbin/logrotate -vf /etc/logrotate.d/linuxaccount
切割後的展示效果
文章簡潔,但都是本人親自使用,並在生產環境運行。請大家支持我哦!
免費領取天貓、淘寶優惠卷