Script to monitor directory size of specific users
Hi,
I want to write a script that display the size of directories created by specfic users for e.g ls -ltr command it shows something like this~ ls -ltr drw-r--r-- 1 abc eng 396 Jun 13 2012 xyz drwxr-xr-x 1 def eng 202 Aug 15 2012 pqr drwxr-xr-x 1 ghi eng 201 Aug 15 2012 stu Now i want to write a script which can monitor size used by users abc,def and ghi to create directories xyz,pqr and stu. Thanks, Nitin |
That's a tad confusing.
xyz, pqr and stu are NOT directories - they are regular files (notice the absence of the "d". You can determine directory size with the du command: du -sh <directory> The -s tells it to summarize (otherwise it would give size of each file in the directory) and the -h tells it to make it human readable. You might want to use -k to get standard size in KB for each entry rather than variable (KB, MB, GB etc...) as reported by -h. Type "man du" for more information. |
Code:
for i in `ls /home`; do find /home/$i -maxdepth 1 -type d -ctime -2 | xargs du -sh ; done Also, the maxdepth can be tweaked or dropped as per your requirement (particularly if you want to know the size of subdirectories further down). |
All times are GMT -5. The time now is 10:56 PM. |