Server Administration & Management

How to clear Disk Space on a Server

Running out of disk space is a very common issue.  Be it a web-hosting service provider or the end-user.  As we know, there are various partitions on a server which are meant for different purposes. So, the methods used to deal with space issues on these partitions will also vary. Let us see them one by one.


/USR partition

1. Restart the httpd service. This might free a little space some times.

2. Check for apache logs like error_log, access_log , suexec_log in /usr/local/apache/logs . These can either be cleared off or if you need the logs then you can take a zipped copy and keep it aside.

3. Same can be done for the files in cPanel logs (/usr/local/cpanel/logs)  as well .

4. Domlogs – Get into  the /usr/local/apache/domlogs/ directory. Run the following command :-

# cd /usr/local/apache/dmlogs/

#  ls -al -SR | head -10        —> It will list 10 files in the decreasing order according to their size

If the domlog file is too large for a domain then it is possible that awstats is not running . Check whether cpanellogd is running on the server  using  pstree . If not, restart it .Else, it is possible that awstats for only that particular domain is not updating. Get into the directory /usr/local/cpanel/base and check if any file as ‘awstats.domainname.com.conf’ exists.   If yes , delete that file. Now,  run /scripts/runweblogs for that user.  It will update the awstats and automatically clear the domlogs file thereafter. Do not delete the domlogs file itself.

# /usr/local/cpanel/base

# rm -rv ‘awstats.domainname.com.conf’

# /scripts/runweblogs

5. Remove old and unwanted backups of  ‘apache’  that might have been taken long ago. Also, check for any other duplicate folders that can be removed safely.

6. Remove core files, if any . Normally, some core files (like core.1234) might be present in /usr/local/cpanel/whostmgr/docroot . Check for these and remove them.


/HOME partition

1.  Check for unwanted cpmove/tar files for the user accounts in /home and delete them.

2.  Check for any cpmove folders as well in /home

3.  Check the folder ‘cprestore’  in /home for any tar files. Be careful. These should  be deleted only if they are very old,say about 4-5 months.

4. Using find command you can check for unwanted tar files(especially cpmove/backup) in the entire home directory. Check their size. If you think that deleting them will  make considerable difference to the disk space then delete them.

5. Check for core files and delete them.

6.  Search for large accounts and see if they are hosting any prohibited content or violating your company policies. If yes, take appropriate measures as per your policies.


/VAR partition

1. Restart the mysql service.

2. Log files in /var/log like exim_mainlog, mailmon.log, messages, mysqld.log, mysql_slow_queries.log  can be deleted after taking backups of the required ones.

# cd /var/log

# echo > exim_mainlog

# echo > mailmon.log

# echo > messages

# echo > mysqld.log

# echo > mysql_slow_queries.log

Note that there is no point in deleting these log files if the size is very small. Check whether deleting these would make any difference. If you are deleting them then do re-create the files, or you can use the command ‘echo ” ” > logfile’ to empty the existing files.

3.  Clear Mysql logs like server-name.err or any other  present  in /var/lib/mysql

# cd /var/lib/mysql

# echo > server-name.err

4. Delete mysql-bin.000* file  in /var/lib/mysql, if present.

5. There might be useless large .sql files   in /var/lib/mysql . Delete them.

6.  Remove unwanted emails from spool. You can use the following code to do that :

# exim -bpc

# exim -bpru | grep frozen | awk {‘print $3′}|xargs exim -Mrm

# exim -bpru | grep “<>” | awk {‘print $3′}|xargs exim -Mrm

# exim -bpru | grep “nobody” | awk {‘print $3′}|xargs exim -Mrm

# exim -bpru|awk {‘print $3′}|xargs exim -Mrm

# exiqgrep -o 86400 -i | xargs exim -Mrm

7. There might be yum cache files inside the /var/cache folder which can take space. To remove them do:

#  yum clear all

#  yum list all

8. Again, search for any core files ( core dump ) like core.12* etc.


/BACKUP partition

1. Remove any tar/cpmove files if they are too old and large.

2. Remove any old  configuration backups ( like apache.bkp) or any log file backup , say 3-4 months old.

3. Check for core files and remove them.

These are some of the general steps that can be followed to deal with space issues on the servers.


August 30, 2011 - Posted by | cPanel, Tips & Tricks, Unix/Linux | , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: