[SOLVED] Logrotate - email log about to be rotated
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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" firstname.lastname@example.org -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)
1. you may need to specify the full path to mutt (like you do for cron jobs)
2. that page says that the script will be run by the /bin/sh shell; have you tested using that shell?
3. This happens every time the logs are rotated; it does not depend on actually reaching a limit of 53 and deleting one; its all about the 'current' logfile...
Sweet! Thank you chrism01! It looks like all that was needed was the full path to mutt. Now every time the log rotates, using logrotate, I get an e-mail with an attachment of the log file just before it is rotated.