3

My logs are being rotated properly, however, I am not being emailed the rotated log. What am I doing wrong?

My main logrotate.conf is:

include /etc/logrotate.d

here is my /etc/logrotate.d/php-errors:

/var/log/php-errors.log {
    rotate 7
    daily
    missingok
    notifempty
    mail me@example.com
}
smusumeche
  • 643
  • 4
  • 8
  • 19
  • 1
    turns out I was misunderstand the mail command. It mails the log that is about to be deleted. I wanted the log that was just rotated, so I had to add the "mailfirst" directive to my configuration file. – smusumeche Dec 17 '14 at 20:53
  • Ah, I hadn't picked up on that error, you're quite right. Please either update your post above to reflect the solution you've found, or post it as an answer below. – BE77Y Dec 18 '14 at 08:52

2 Answers2

4

You will need to ensure that you have sendmail (or an equivalent MTA) correctly configured to be capable of sending mail out, then specify the full path to the command in your configuration as above in /etc/logrotate.d/php-errors;

/var/log/php-errors.log {
    rotate 7
    daily
    missingok
    notifempty
    /bin/mail me@example.com
}
BE77Y
  • 2,667
  • 3
  • 18
  • 23
  • I do have sendmail setup and it works on the system. When I put the absolute path like you suggested, I get this error: unexpected log filename – smusumeche Dec 17 '14 at 20:44
4

Turns out I was misunderstand the mail command. It mails the log that is about to be deleted. I wanted the log that was just rotated, so I had to add the "mailfirst" directive to my configuration file.

smusumeche
  • 643
  • 4
  • 8
  • 19