Skip to content

Instantly share code, notes, and snippets.

@murayama
Created July 9, 2013 01:22
Show Gist options
  • Save murayama/5953909 to your computer and use it in GitHub Desktop.
Save murayama/5953909 to your computer and use it in GitHub Desktop.
ログローテート時にS3に転送する
$ sudo yum -y --enablerepo epel install s3cmd
$ s3cmd --configure
/var/log/messages {
    daily
    rotate 1
    missingok
    compress
    create
    dateext
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    lastaction
        /usr/bin/s3cmd put --config=/home/ec2-user/.s3cfg /var/log/messages-`date '+%Y%m%d'`.gz \
        s3://example-log-backup/logs/`date '+%Y'`/`date '+%m'`/`date '+%d'`/messages-`date '+%Y%m%d'`.gz
    endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment