LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How Do I Clean /var Storage on Dedicated Server? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-clean-var-storage-on-dedicated-server-786985/)

mindtattoos 02-04-2010 09:56 AM

How Do I Clean /var Storage on Dedicated Server?
 
The /var directory is 97% full on my dedicated server:

I would like to know if it is safe to clear it and how to clear it (assuming it will not disrupt/kill server services to do so).

I have Matrix control panel so i can view the storage etc but it does not have an way of clearing the /Var directory.

I have Putty Access to root but do not know which command to use.

I found a few threads but the information is not clear to me as there seems to be an assumption of basic knowledge I don't yet have.

My linux/ubuntu support that usually does this kind of thing for me is away and not contactable and my server is grinding to a halt and unable to store/send email.

I have only a very basic understanding of command line but really need to get this sorted ASAP.

Thanks
:o

Samael 02-04-2010 11:04 AM

I have to do this regularly at work for some old FreeBSD machines we use. It'll probably be different process depending on how your machine is setup. We use Qmail and ClamAV, so when clearing space we generally clear unnecessary ClamAV logs and the logs for messages that have been sent by Qmail.

Check the amount of space you have by:

cd /var
du -h

++nick++ 02-04-2010 04:03 PM

Hi,

You can "rm -vf" old files in /var/log/ , that should help you free up some space

chrism01 02-04-2010 05:29 PM

Start by getting a listing of the contents of /var

du -sk /var |sort -nk1

there are several dirs under /var; you need to treat them separately.
In eg /var/log you may see

messages
messages.1.gz
messages.2.gz

and similar.
A similar arrangement usually applies to other file in othe dirs under /var.
You can use

ls -lt to check/sort by date.

The 'current' file is the one without the number or gz extensions. Note that many orgs require you to keep backups of old logs, so do that first before removing them.
For safety's sake, use the rm cmd on one file at a time, no wildcards.

You should be controlling most logs via the logrotate facility; see /etc/logrotate.d dir.
Its possible you need to adjust the params in those files to rotate the files (ie close old file/gzip/start new file) more frequently.
It also sounds like your backup/archival system has either failed or needs tweaking in a similar way.
Normally the logs are self managing on a well run system.

Do NOT just blindly start deleting stuff, you will regret it.

Can you confirm your distro & version?
If necessary, post lists of the /var dirs so we can help.


All times are GMT -5. The time now is 08:26 AM.