Log Problem and bash script
- by GvWorker
Hello Guys,
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.
When I delete files from server hdd will free up without rebooting
Log should be in specific range. Like a specific size of file where old data overwrite with new data