0

I've configured it to run hourly, it rotates logs hourly but not sending it to s3, what could be the reason?

/var/log/newlog {

rotate 5
hourly
missingok
notifempty
compress
dateext
    dateformat -%Y-%m-%d-%H%M%S
postrotate
    /usr/lib/newlog/new
endscript

/usr/lib/newlog/new is a script, using s3cmd to sync .gz files to s3

KB11
  • 1
  • 1

1 Answers1

0

From the above code it is seen that, there is no mention of S3 bucket to which the log files should be compressed. Your script should add the following lines:


/var/log/newlog {

   postrotate
    /usr/lib/newlog/new > /dev/null 2>&1 || true

    BUCKET=logging-bucket
    INSTANCE_ID=`curl --silent http://169.254.169.254/latest/meta-data/instance-id | sed -e "s/i-//"`
    /usr/bin/s3cmd -m text/plain sync /var/log/messages-* s3://${BUCKET}/${INSTANCE_ID}/var/log/

endscript

}


where logging-bucket is name of the bucket in which the compressed files will be stored. Also make sure the user has permissions to the S3.

Thanks