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
}
  • 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 8:52
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
}
  • 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.