Skip to content

Instantly share code, notes, and snippets.

@uran1980
Forked from aputs/logrotate-nginx
Created August 3, 2013 09:14
Show Gist options
  • Save uran1980/6145815 to your computer and use it in GitHub Desktop.
Save uran1980/6145815 to your computer and use it in GitHub Desktop.
/var/log/nginx_*.log {
daily
compress
delaycompress
rotate 2
missingok
nocreate
sharedscripts
postrotate
test ! -f /var/run/nginx.pid || kill -USR1 `cat /var/run/nginx.pid`
endscript
}
/var/log/php-fpm.log {
daily
compress
delaycompress
rotate 2
missingok
notifempty
create 644 root root
sharedscripts
postrotate
/sbin/service php-fpm flush-logs > /dev/null
endscript
}
#keep a whole year of logs
#rename logs to %Y%m%d/+%Y%m%d.access
/var/log/smartwap/access.log {
daily
nocompress
rotate 365
missingok
nocreate
sharedscripts
postrotate
FNAME=`echo $1 | sed -e 's/ *$//'`.1
DIR=`dirname $FNAME`/`date --date='-1 day' +%Y%m`
EXT=`basename $1 | cut -d'.' -f1`
DEST=$DIR/`date --date='-1 day' +%Y%m%d`.$EXT
mkdir -p $DIR
mv $FNAME $DEST
test ! -f /var/run/nginx.pid || kill -USR1 `cat /var/run/nginx.pid`
endscript
}
#error logs
/var/log/smartwap/error.log {
daily
compress
delaycompress
rotate 2
missingok
nocreate
postrotate
test ! -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