Introduction
Sometimes you may encounter issues with your server or parts of the hosted services such as service errors or issues with server connectivity. The first point that you should check in such scenarios is the server disk space usage. Every service requires a specific amount of disk space for it to work and produce a stable performance, it can cause swapping/paging issues without a sufficient free disk availability in server. If the server disk space usage is 100%, the first place to search is the server logs files. In most of the Linux distributions, the /var/log location is used to store the general service logs. You can navigate to the location and remove any rotated log files which are very old and less relevant. You can use the below command to navigate to the location and list the directories and files based on their disk usage.
cd /var/log du -sch ./*
You can use the command rm -f to remove any large sized or rotated log files.
rm -f exim_paniclog-* to remove all rotated exim_paniclog files and rm -f exim_mainlog-* remove all rotated exim_mainlog files and so on. We can proceed to further cleaning after releasing at least 100MB – 200MB space by clearing the logs files as we discussed earlier.
Check for backup files
Check the web spaces for any redundant data like backup files created for the documents, directories, databases, uploaded backup files etc, download them to your local workstation and remove the server copies. Check if you have configured any automated backup from the control panels, verify the backup location and remove any old backups
Check cache, session and temp directories.
Check the cache directories, php session directories (check session.save_path in php.ini), temp/tmp directories in your server. It is advisable to clear cache, session and temp data files older than 7 days, please check with your web developer if you are not sure about the validity of such data. You can navigate to those directory locations in an SSH session as root user and execute the below find command to remove files older than 7 days.
cd /<location>/ find . -type f -mtime +7 -exec rm {} \;
Check the current disk space usage usage with the command df -h and make sure the server have atleast 10GB of free space or based on your application’s requirement.
Verify the disk space usage from the directory structure by du -sch /*
Continue the procedure recursively to the internal directories like du -sch /home/* du -sch /backup/* so that you will get an idea of the disk usages by various subdirectories.