Pages

Bài đăng phổ biến

Showing posts with label nginx with logrotate. Show all posts
Showing posts with label nginx with logrotate. Show all posts

Saturday, June 27, 2015

Logrotate with nginx

/path_to_accesslog/access.log {
    missingok
    notifempty
    size 100000k
    daily
    create 0644 www root
    postrotate
[ ! -f /etc/nginx/logs/nginx.pid ] || kill -USR1 `cat /etc/nginx/logs/nginx.pid`
    endscript
}

Explain:

missingok :  do not output error if logfile is missing
notifempty : do not rotate if logfile is empty
size             : Log file is rotated if it is  bigger than 100000KB
daily            : daily rotation
create 0644 www root : create new logfile with permission 644 where owner is www and group is root user.
postrotate
[ ! -f /etc/nginx/logs/nginx.pid ] || kill -USR1 `cat /etc/nginx/logs/nginx.pid`
    endscript

=> tells nginx reload the log files .

Finish!!!

Nguyen Si Nhan