Randomly Expressed


Welcome to my blog “randomly expressed”. I created this website to publish helpful tips. It’s mainly technology driven, but I will blog about other topics. I am a Unix sysadmin that is always looking to learn new things. My goal is to be able to share knowledge that others may find useful. xkcd.com

Continue Reading »


Connect With US

Connect with us on the following social networking sites.

Most Popular Posts.

Add Some Content to This Area

You should either deactivate this panel on the Theme Settings page, or add some content via the Widgets page in your WordPress dashboard.

Diagnosing Linux disk space usage

By on February 15, 2015 in Technology with No Comments

Disk space
Isolating what files or directories are consuming the most space is crucial when troubleshooting disk utilization problems. The du command with the -kx options is the ideal tool for this job. The k option is for displaying block counts in 1024-byte (1-Kbyte) blocks. I prefer kilobytes because it sorts better than gigabytes. The x option is so file system mount points are not traversed. You don’t want to waste time searching a large 10TB NFS mount point when you are only concerned about the 20GB local file system.

~$ sudo du -kx / | sort -nr | more
2810724 /
1552048 /var
896116 /usr
653656 /var/www
471572 /var/lib
437180 /var/www/wordpress
418432 /var/www/wordpress/wp-content
382020 /var/www/wordpress/wp-content/themes
355004 /usr/lib
248892 /var/lib/varnish
230000 /usr/share
210928 /var/cache
208544 /var/log
186272 /var/www/wordpress/wp-content/themes/tiny-forge
186080 /home

Once you find the directory that is consuming the most space you can run the following one liner to compress any log file that is older than 7 days. (Assuming it’s log files.) Ideally log files should be put under a log rotation schedule via logrotate. Run the following command from within the directory that contains the log files.

find . -type f -name "*.log" -mtime +7 -print -exec gzip {} \;

Additionally if you don’t need the log files, then you can simply delete them instead of compressing them.

find . -type f -name "*.log" -mtime +7 -print -exec rm -fr {} \;

Facebook Comments

Tagged With:

Post a Comment

Your email address will not be published. Required fields are marked *