PDA

View Full Version : Not able to mail logfiles using logrotate



agarud
30-Jul-2015, 09:37
Hello All,

I have setup a new log and want to mail the log file daily at the end of the day. Logrotate has a mail and mailfirst option available, but it sends the content of the log file in mail but does not send the logfile as an attachment. Does logrotate behave like this or is there any other option which attaches the actual logfile?

Here are the contents of the file.

/etc/logrotate.d/script_mem
/opt/test_cron.log
{
daily
rotate 3
dateext
compress
mail ***@****.com
mailfirst
}

Thanks,
agarud

jmozdzen
30-Jul-2015, 12:14
Hi agarud,

> Does logrotate behave like this

from "man logrotate":


-m, --mail <command>
Tells logrotate which command to use when mailing logs. This command should accept two arguments: 1) the subject of the message, and 2) the recipient. The command must then read a message on standard input and mail it to the recipient. The default
mail command is /bin/mail -s.

Regards,
Jens

agarud
31-Jul-2015, 07:55
Hi agarud,

> Does logrotate behave like this

from "man logrotate":

[/COLOR]

Regards,
Jens
[/FONT]

HI Jens,

Used the full path for the mail option but still it does not send the attachment.



thanks
agarud

jmozdzen
31-Jul-2015, 10:38
Hi agarud,


HI Jens,

Used the full path for the mail option but still it does not send the attachment.

the key may be the following part of the man page: "The command must then read a message on standard input and mail it to the recipient." As the mail command puts everything from stdin into the body of the message, nothing es is to be expected.

Regards,
Jens