Created
January 9, 2017 10:05
-
-
Save acsrujan/469d44d6ac67d27d5967cdfe78c9a927 to your computer and use it in GitHub Desktop.
logrotate config with most of the options.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#To rotate file every 100kb, truncate the file and delete the older logs. | |
#This keeps only latest 100kb. | |
/var/logs/randomdump.log | |
{ | |
size 100k | |
copytruncate | |
rotate 0 | |
} | |
# Copytruncate avoids file delete and create new file. | |
#This keeps 7 rotated files | |
/var/logs/access.log | |
{ | |
size 100k | |
copytruncate | |
rotate 7 | |
} | |
#Rotates file weekly, keeps 10 older files, doesn't create new file (hence, no restart or reload process) | |
/var/log/postgresql/*.log { | |
weekly | |
rotate 10 | |
copytruncate | |
delaycompress | |
compress | |
notifempty | |
missingok | |
su root root | |
} | |
#User remains intact in rotation. | |
/var/log/mongodb/*.log { | |
weekly | |
rotate 10 | |
copytruncate | |
delaycompress | |
compress | |
notifempty | |
missingok | |
} | |
#Nginx logrotate | |
/var/log/nginx/*.log { | |
weekly | |
missingok | |
rotate 52 | |
compress | |
delaycompress | |
notifempty | |
create 0640 www-data adm | |
sharedscripts | |
prerotate | |
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ | |
run-parts /etc/logrotate.d/httpd-prerotate; \ | |
fi \ | |
endscript | |
postrotate | |
[ -s /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid` | |
endscript | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment