2

I have 11 Debian servers running on rackspace cloud hosting. All running VHCS2 for hosting management. 1 server is used for application and 10 are used for only smtp. My question is regarding smtp servers. Each server hosted 1 domain. My problem is when my client use smtp there's a log created in this directory

/var/log/

but within 24 hours drives are full and server refuse all smtp connections. Then I deleted the logs and ran following command to check the disk space.

df -h

but it shows hdd still full and server is still refusing the smtp connections. Then I ran following command to see the truth

du --max-depth=1 -h

It shows the truth. The real disk space used. Then I rebooted the server and now server working fine. But after few hours same situation happened. Then I created the following script.

#!/bin/sh

rm -fr /var/log/*
rm -fr /var/log/apache2/*.log
rm -fr /var/log/apache2/*.log.*
rm -fr /var/log/apache2/users/*
rm -fr /var/log/apache2/backup/*

reboot

It worked for days but after that logs are again filling the hdd.

Now I want the following solutions. If anybody can help me.

  1. When I delete files from server hdd will free up without rebooting
  2. Log should be in specific range. Like a specific size of file where old data overwrite with new data

2 Answers2

7
  1. Deleting the log files alone won't help. You need to tell the daemon to close the log file, usually by sending it a SIGHUP.
  2. logrotate should be handling the logs, and it can use various criteria to determine when the log should be rotated.
  3. Your logs are filling up awful fast. Either figure out what's flooding your logs, send your logs to another machine for handling and storage, or mount a separate volume at /var/log so that it will be the only volume affected.
Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84
4

You really need to work out which log(s) are filling the disk. Once you know which logs are the problem take a look at them and see why they are growing so quickly.

Is there too much information being logged ? Reduce the logging level of the application.
Are lots of errors being logged ? Investigate and fix.
...

Once you have control of the logs you can then use logrotate to help manage them.

user9517
  • 115,471
  • 20
  • 215
  • 297