How to display directory size?
Hi,
I have many directories under /home. What is the fastest way to find who is taking lot of space. So for this is what I did. Code:
cd /home My goal is, I want to send email each month how much space is under their directory. Thanks. |
There is no faster alternative to the du command. To accomplish your task it would be advised to create a shell script that does a du of each home directory independently, du does not take much resources and will complete faster if you run a seperate process for each directory. You can then do a test with an if statement or a similar function and email out any directories that are over a certain size.
|
You can also check with the help of Disk Usage Analyzer. In Gnome it is under Applications --> Accessories --> Disk Usage Analyzer.
|
Quote:
Try a basic script such as below set up on a monthly cron job and modify it for your needs. This is a simply for loop but you can make it a better script by doing it in a few different ways, I'm just a bit lazy right now. Code:
#!/bin/bash |
You can also use this code written in perl:
Quote:
|
I use python over perl but still a decent script if you want to go that route. However, you would want to use du instead of df as it is more accurate and in some cases df can provide very inaccurate results. I've run into several issues where syslog processes where causing df to read higher disk usage by almost 20 GB even though the files it had open were no longer that size.
|
Hi,you can use this command
Code:
du -h --max-depth=1 /home/|sort -hr |
Thank you so much for your all help. The script really helps. I will add this to my cronjob.
|
All times are GMT -5. The time now is 07:33 AM. |