Created
February 22, 2012 01:10
-
-
Save tovbinm/1880359 to your computer and use it in GitHub Desktop.
Logrotate & upload nginx logfiles to s3://bucket/dt=..../hostname.log...gz
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
# Nginx - logrotate & upload to S3 | |
0 0 * * * /usr/sbin/logrotate /etc/logrotate.d/nginx | |
15 0 * * * s3cmd put /var/log/nginx/access.log-`date +"\%Y\%m\%d"`.gz s3://$LOGS_BUCKET_NAME/nginx-access/`date +"dt=\%Y\%m\%d"`/`hostname -s`.access.log-`date +"\%Y\%m\%d"`.gz |
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
/var/log/nginx/error.log { | |
daily | |
rotate 30 | |
copytruncate | |
compress | |
notifempty | |
missingok | |
} | |
/var/log/nginx/access.log { | |
daily | |
rotate 30 | |
compress | |
missingok | |
notifempty | |
sharedscripts | |
dateext | |
postrotate | |
kill -USR1 `\/usr\/bin\/pgrep -f \/usr\/local\/nginx\/sbin\/nginx` \ | |
endscript | |
} |
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
find /var/log/nginx/ -type f -mmin -10 -name "access.log*.gz" -exec sh -c "s3cmd put {} s3://$LOGS_BUCKET_NAME/nginx-access/\`date +\"dt=%Y%m%d\"\`/\`hostname -s\`.\`basename {}\`" \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
but s3cmd command is not sending/uploading the latest log file on s3.