Logrotate - email log about to be rotated
Hi,
I have been trying for some time now to figure out how to send a log file as an email attachment. I have found how to send files as attachments using mutt: mutt -s "Report Attachment" user@domain.com -a /var/log/rbgaTcp.log < /home/user/messageBody. This string entered in the command line will send the log file located in /var/log, and include the text in the file /home/user/messageBody, in the message body. That is great but what I can't seem to figure out is how to send the log file before it is rotated per the logrotate schedule?
I understand the mail command in the logrotate config file, sample below, will only send mail when a file is rotated out, ie deleted from the system. This is not what I need to do. I have tried putting the mutt string, above, between the firstaction and prerotate options, being sure to end it with endscript. No love. :-( I also put the mutt string in a separate shell script and call that from prerotate, again no love. :-(
Any thoughts are greatly appreciated. Thank you in advance.
SAMPLE FILE: (located in /etc/logrotate.d/configFileName)
/var/log/rbgaInternet.log /var/log/rbgaTcp.log /var/log/rbgaUdp.log {
rotate 53
daily
#firstaction
# mutt -s "Report Attachment" user@domain.com -a /var/log/rbgaTcp.log < /home/user/messageBody
#endscript
prerotate
/home/user/mailLog.sh
endscript
create 666
}
Last edited by killminus9; 05-23-2012 at 07:30 PM.
|