-
Notifications
You must be signed in to change notification settings - Fork 44
Managing log files by using logrotate utility
Taymindis Woon edited this page Nov 16, 2020
·
2 revisions
sudo vim /etc/logrotate.d/nginx
/etc/nginx/logs/*.log {
daily
missingok
rotate 31
compress
delaycompress
notifempty
create 640 myusername adm
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
- size limit rotate
- max rotated file is 31 count
- older than 31 days auto remove
- specified backup extension
please follow the step below:-
/var/log/nginx/*.log {
su appsadmin appsadmin
size 256M
missingok
rotate 31
compress
delaycompress
dateext
dateformat -%Y%m%d_%H%M
maxage 30
notifempty
create 640 appsadmin appsadmin
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
sudo logrotate /etc/logrotate.d/nginx
use sudo crontab -e
for create auto logrotate daily
0 0 * * * /usr/sbin/logrotate -f /etc/logrotate.d/nginx