Skip to content

Instantly share code, notes, and snippets.

@jamiehs
Created March 23, 2013 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiehs/5228552 to your computer and use it in GitHub Desktop.
Save jamiehs/5228552 to your computer and use it in GitHub Desktop.
A script such as the one above should be added to the file /etc/logrotate.d/nginx for each vhost you are hosting which store their logs separate from Nginx’s main logs in order to cut back on the space being used to store these log files. THis Gist is basically a copy of Nginx’s own log rotation script and can be tailored to fit your needs. For …
/path/to/vhosts/domain.com/logs/*.log {
daily
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
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment