I am trying to use logrotate to upload log files from my rails and nginx commands once a day. When I run the logrotate command manually the files successfully upload, but it never does it on its own. I have tried using lastaction and also postrotate but neither actually uploads to S3. Is there something trivial that I'm missing?
/home/deploy/www/mysite.com/log/*log {
su
daily
dateext
dateformat _%Y_%m_%d
rotate 3
missingok
dateext
compress
delaycompress
notifempty
copytruncate
sharedscripts
lastaction
rvmsudo passenger-config reopen-logs;
/usr/bin/s3cmd sync /home/deploy/www/mysite.com/log/*.gz s3://mysite_com/logs/rails/
endscript
}
EDIT: Below is the corrected way of doing this. So instead of using the lastaction script, call a shell script instead.
lastaction
./rails_reload_and_upload.sh
endscript
which contains
#/bin/bash
./reload_rails_logs.sh
/usr/bin/s3cmd --config /home/username/.s3cfg sync /home/deploy/www/mysite.com/log/*.gz s3://mysite_com/logs/rails/