0

I have AWS linux instance, Currently there are many folders in the instance.
I would like to map all the folders and their size, so i could come back in 1 month and check which folder occupy high amount of storage (maybe the logging folder).

What is the best way to achieve this ?
so i could compare the size of this month and next month more easily.
Thanks.

ewwhite
  • 194,921
  • 91
  • 434
  • 799
ilansch
  • 179
  • 2
  • 12
  • what you are meaning by 'map all folders' ? – Suku Jan 14 '13 at 17:02
  • 1
    I suspect you want something like `du -sc /folders_to_map/ > my_logfile`, but your post is not clear enough. Can you clarify your goal? – Hennes Jan 14 '13 at 17:08
  • Hey, I want to map all the file structure, to make output file that says: /etc/folder 50 MB, /etc/bin 60 MB. so i could come back in the end of the month and see which folder increased in size.. one of my folders occupy 2 GB every 2 months i need to locate the fat folder :) – ilansch Jan 15 '13 at 06:09

3 Answers3

2

I saved this answer from another question a while ago: How can I sort du -h output by size

Requires coreutils 7.5 or newer. The command is simple:

du -hs * | sort -h

Or to sort in descending order, use:

du -hs * | sort -hr

The output will list directories in order of size, sorted in human readable format (K, M, G)

To compare sizes over time, redirect the output to a file for storage:

du -hs * | sort -hr > /path/to/diskusage.txt
JKim
  • 552
  • 3
  • 10
2

Use the ncdu utility. Record the values. Come back and check again in a month :)

ncdu 1.7 ~ Use the arrow keys to navigate, press ? for help                                                         
--- /ppro ----------------------------------------------------------------------------------------------------------
  170.0GiB [##########] /data                                                                                       
  104.6GiB [######    ] /sldata
   54.4GiB [###       ] /isam
   48.8GiB [##        ] /slisam
   27.8GiB [#         ] /hist
   15.4GiB [          ] /prt
   12.1GiB [          ] /jmail
   10.1GiB [          ] /zephyr2
    9.7GiB [          ] /edi    
    7.9GiB [          ] /savdata2
    6.2GiB [          ] /io      
ewwhite
  • 194,921
  • 91
  • 434
  • 799
1

The answer was to make a bash script.
This is part of the script:
I output the information of each mail folder sub folders, e.g:

#!/bin/bash
du -h /etc/* | sort -nr | head -n 20 > /outputdir/data/etc.txt
du -h /usr/* | sort -nr | head -n 20 > /outputdir/data/usr.txt
du -h /var/* | sort -nr | head -n 20 > /outputdir/data/var.txt

plus adding

du -hs /var/ >> /ilantest/data/general.txt
du -hs /usr/ >> /ilantest/data/general.txt
du -hs /etc/ >> /ilantest/data/general.txt

This will give me some information on disk usage for most used folders, including to display to top 20 biggest folders and their changes during the tests.

Jeff Ferland
  • 20,239
  • 2
  • 61
  • 85
ilansch
  • 179
  • 2
  • 12