in Work

Server Storage Space Management

For users running CPanel there’s a handy tool labeled “Disk Space Usage” that sums up the general usage of your hosting space. But that’s the most it can do, a summary of usage for each of the folders on on the root directory for the user. If you want to go deeper or check on individual files you’ll need something more.

 

Finding all file sizes with the “du” command

The following command will display all files and folders sorted by MegaBytes.

du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'

You should see an output of all your folders with the size of them in megabytes similar to the following:

0 MB ./.htpasswds
0 MB ./.trash
0 MB ./public_ftp
0 MB ./etc
0 MB ./.fontconfig
0 MB ./.cpanel
0 MB ./mail
4 MB ./tmp
1173 MB ./public_html
1224 MB .

This output shows that all files over 1 MB are in the /public_html. You can run this command on a directory basis to find folders that are large. Also, this command can be customized to refine your search.

Finding specific file sizes using the “find” command

Below is the “find“command that looks for specific files in the “home” directory. The following script is finding files that are 500000k or larger

find /home -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

The previous command will output a similar result like the following.

/home/userna5/public_html/error_log: 514M
/home/userna5/backup-userna5.tar.gz: 738M

Here you can see that there is a backup that is 738MB large. You can find your backup files that are no longer needed and remove them to free up space.

 

Echoed from: http://www.inmotionhosting.com/support/website/general-server-setup/check-disk-space-through-shell

 

 

Write a Comment

Comment