我已经设置了每周创build新的日志文件。
不过,我想先把邮件作为附件邮寄给我。
/var/log/httpd文件当前包含:
/var/log/httpd/*log { missingok notifempty sharedscripts firstaction {I think I need to mail the logfiles here???} postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript }
是否有可能做我想要的?
如果是这样的话:我需要添加firstaction以便它的firstaction :
/var/log/httpd/*log )作为附件发送给我 HTTPD logfiles {week #} 如果我正确理解你的问题,有一个logrotate选项可以做你想做的事情。 只需将mail [email protected]添加为其中一个configuration选项,如下所示:
/var/log/httpd/*log { mail [email protected] ...
这会向您发送即将被旋转的日志文件。
也许你已经尝试过,并没有完全满足你的需求。 在这种情况下,我认为你大部分时间都处于正确的轨道上。 但是,当您尝试使用附件发送消息时,直接调用sendmail不是正确的方法。 引用sendmail FAQ :
如何使用sendmail创build附件?
你没有。 Sendmail是一个邮件传输代理(MTA)。 创build电子邮件,包括添加附件或签名,是邮件用户代理(MUA)的function。 一些stream行的MUA包括mutt,elm,exmh,Netscape,Eudora和Pine。 一些专门的软件包(metamail,一些Perl模块等)也可以用来创build带有附件的消息。
如果你有邮件用户代理mutt (或可以安装它),它应该能够做你想做的。 尝试这样的事情:
/var/log/httpd/*log { firstaction echo | mutt -s "Log files for `date`" [email protected] -a /var/log/httpd/*log endscript ...
还要注意在你的示例configuration文件中,你错过了endscript firstaction命令的firstaction 。