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

tighernain
Posts: 24
Joined: Tue Dec 27, 2016 5:33 am

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

Postby tighernain » Tue Jun 06, 2017 5:26 am

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.

User avatar
bigfoot65
Project Manager
Posts: 11924
Joined: Mon May 25, 2009 4:31 pm

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

Postby bigfoot65 » Tue Jun 06, 2017 8:23 am

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.
ßîgƒσστ65
Applications Manager

My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 16GB RAM, 1TBx1+2TBx2+4TBx2

tighernain
Posts: 24
Joined: Tue Dec 27, 2016 5:33 am

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

Postby tighernain » Wed Jun 07, 2017 4:20 am

Hi mate,

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

User avatar
bigfoot65
Project Manager
Posts: 11924
Joined: Mon May 25, 2009 4:31 pm

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

Postby bigfoot65 » Fri Jun 09, 2017 6:55 pm

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
ßîgƒσστ65
Applications Manager

My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 16GB RAM, 1TBx1+2TBx2+4TBx2

tighernain
Posts: 24
Joined: Tue Dec 27, 2016 5:33 am

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

Postby tighernain » Fri Jun 09, 2017 8:13 pm

Many thanks :) All sorted

User avatar
bigfoot65
Project Manager
Posts: 11924
Joined: Mon May 25, 2009 4:31 pm

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

Postby bigfoot65 » Sat Jun 10, 2017 7:06 am

No problem.

Marking as solved.
ßîgƒσστ65
Applications Manager

My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 16GB RAM, 1TBx1+2TBx2+4TBx2

Who is online

Users browsing this forum: No registered users and 28 guests