Quote:
Originally Posted by ranger_nemo
Sounds like a good time to learn bash scripting.
"du -hs /home/*" as root will give you the size of each directory in /home.
"du -hs /home/* | sort -r" will sort them from largest to smallest.
"du -hs /home/* | sort -r > /root/home_report" will put them into a file you can mail to yourself.
"mail" is the program you will use to send yourself the report. Haven't used it, so I can't really help you there.
You can put it all into a couple-line bash script, and put that into your cron.
Or... Set-up disk quotas...
|
I have a small correction.
"sort -r" will not accomplish what you want to to for 2 reasons.
1) "sort -r" only reverses the sort order, if the "du" command sends it out of order, the "sort -r" will not fix it only reverse it.
2) "du -hs" will put the results in a human readable form. This means that 281K will be considered a higher number that 142G by the "sort" command.
A better, albeit less readable, solution would be:
"du -s /home/* | sort -nr"
As for mailing the results, you can use the following command to email the results:
"du -s /home/* | sort -nr | mail -s 'Home Directory Usage'
email@domain.com"
I use the following crontab command to monitor my /var directory (Website and log files can get out of control). It mails me the results every Sunday night.
00**0 root du -s /var/* | sort -nr | mail -s 'Var Directory Usage'
address@domain.com