1

I have an issue with Ubuntu 14.04 server.

The issue is that the /var/log/mail.log is getting huge and its saturating the server.

My question is: is there a way to do some automatic log rotating so I can limit the log size to some reasonable size?

2

The default application to do that is logrotate. The config file has some examples on how to rotate. But something like this:

/var/log/mail.log
{
    rotate 7
    daily
    missingok
    notifempty
    delaycompress
    compress
    postrotate
        reload mail.log >/dev/null 2>&1 || true
    endscript
}

for a 7 day rotation.

But! Do have a look at your mail.log and see if what is put in there is not an ERROR or someone abusing your system as a relay to send out spam.

| improve this answer | |
  • Yes you where right , we had nonworking smtp server that caused the log to accumulate – user1289947 Mar 7 '16 at 14:39
  • Thanks for the log rotation script , question how should i implement it , should I use cron ? if yes can you elaborate with me example ,Thanks – user1289947 Mar 7 '16 at 14:41
  • logrotate uses its own daemon. – Rinzwind Mar 7 '16 at 14:44
  • logrotate usually installs its own cron file in /etc/cron.daily/logrotate, so runs daily by default. – meuh Mar 7 '16 at 16:01
  • @user1289947 As you've never accepted an answer on this site before: If this answer helped you, don't forget to click the grey at the left of this text, which means Yes, this answer is valid! ;-) – Fabby Mar 8 '16 at 20:26

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.