Page 1 of 1

SOLVED: Drive filling up. How to limit the log size of Monit

Posted: Tue Jun 06, 2017 5:26 am
by tighernain
Hi guys,

I have noticed a problem with log files on my system that are growing and slowly filling up my small boot and / drive. After a bit of work it seems the culprit is the Monit log file. Any ideas on how to limit the Monit log file to a sensible size?

My server is not very standard as I have a 64Gb SSD drive from which I boot and have the OS installed on, plus a Raid 5 array of 4 disks with all my shares. Hence I have steadily noticed a slow decrease in available disk space on my boot drive.

Thanks in advance for the help.

Re: Drive filling up. How to limit the log size of Monit

Posted: Tue Jun 06, 2017 8:23 am
by bigfoot65
My first concern would be why the log file is getting so large. Are there errors being repeatedly written to the file? If so, the answer would be to correct them, not limit the log size.

BTW, log files are rotated when they reach a predetermined size. The old logs are often gzipped or sometimes just renamed with a date stamp added.

The best option is to eliminate the back up logs from the /var/log directory. I created a bash script on my HDA to do just that. I can set it to run periodically via a cron job or just manually.

Re: Drive filling up. How to limit the log size of Monit

Posted: Wed Jun 07, 2017 4:20 am
by tighernain
Hi mate,

Yep its just the backup logs. Good idea about the script. Any chance that you can share? :)

Re: Drive filling up. How to limit the log size of Monit

Posted: Fri Jun 09, 2017 6:55 pm
by bigfoot65
I basically created a script file in my user's directory as follows:
sudo rm -rf /var/log/*.gz
sudo rm -rf /var/log/*.log-2017*
sudo rm -rf /var/log/*-2017*
I then made it executable, and run it occasionally.

You could also create a cron job to run it periodically.

This is another one I found searching the internet to remove log older 180 days:
#!/bin/sh
find /var/log/ -type f -mtime +180 -delete

Re: Drive filling up. How to limit the log size of Monit

Posted: Fri Jun 09, 2017 8:13 pm
by tighernain
Many thanks :) All sorted

Re: Drive filling up. How to limit the log size of Monit

Posted: Sat Jun 10, 2017 7:06 am
by bigfoot65
No problem.

Marking as solved.