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.

3
  • what you are meaning by 'map all folders' ?
    – Suku
    Commented Jan 14, 2013 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
    Commented Jan 14, 2013 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
    Commented Jan 15, 2013 at 6:09

3 Answers 3

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      
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
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .