LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-20-2012, 05:10 AM   #1
nicksrulz
LQ Newbie
 
Registered: Mar 2012
Posts: 4

Rep: Reputation: Disabled
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

Last edited by nicksrulz; 03-28-2012 at 04:21 AM.
 
Old 03-20-2012, 07:05 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 03-20-2012, 07:19 AM   #3
eosbuddy
Member
 
Registered: Feb 2012
Location: India
Distribution: Ubuntu, Fedora, Gentoo, Mandrake, RedHat, CentOs
Posts: 30

Rep: Reputation: Disabled
Code:
for i in `ls /home`; do find /home/$i -maxdepth 1 -type d -ctime -2 | xargs du -sh ; done
You can drop the ctime directive if it is not needed (will give you more lines of output and particularly if you're going to monitor on a day to day basis, you might want it to be there).
Also, the maxdepth can be tweaked or dropped as per your requirement (particularly if you want to know the size of subdirectories further down).

Last edited by eosbuddy; 03-20-2012 at 07:25 AM. Reason: Update
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
assign disk quota or size limit to a specific directory or folder on fedora abhijit_mohanta Linux - General 2 08-10-2009 03:04 AM
downland limit size for specific users cb777 Linux - Newbie 1 02-26-2009 09:51 AM
Monitor directory size in real-time billygoat32 Linux - Software 2 10-28-2005 09:21 AM
Limit Users Home Directory Size KrGAce Linux - Newbie 6 10-24-2005 09:48 AM
wu-ftp confine real users to a specific directory thb Linux - Networking 1 02-06-2002 07:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration