Computing.Net > Forums > Unix > Script to get disk usage per month.

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Script to get disk usage per month.

Reply to Message Icon

Name: camin
Date: May 5, 2004 at 06:44:37 Pacific
OS: SunOS 5.8 Generic_108528
CPU/Ram: unknown
Comment:

Hi,

I need a script on how to get disk usage of files that was added into a dir from Jan 1, 2004, and disk usage per month. Can someone help please.....!
camin



Sponsored Link
Ads by Google

Response Number 1
Name: camin
Date: May 19, 2004 at 13:08:24 Pacific
Reply:

Hi,
I have started this but need some assistance...grateful for any help...thanks.

Here is what I need to get..

1. Find all files that have been added to (some dir) since Jan 5/2004
2. Find total number of files which have been added since Jan 5/2004
3. Find total number of diskspace occupied by those files
4. Find total number of directories that contain files. Some directories maybe empty.

Here is what I did:

# Find all files with the date of Jan 01/2004
touch -t 200312312359.59 $workdir/Dec31
find $home/allbinaries -type f -newer $workdir/Dec31 >file2.txt

# Find total number of files

totalfiles=`wc -l $workdir/file2.txt`
echo "Total number of files $totalfiles" >$workdir/results.txt

# Find total number of diskspace occupied by those files

totaldsksp=`du -sk $workdir/file1.txt`
echo "Total diskusage of new files from Jan 1, 2004 $totaldsksp" >>$workdir/results.txt

# Find total number of directories that contain files

cat $workdir/file1.txt | while read record;
do
if test -d $record && test -d != ""
then
I am stuck here I do not know if this would be the way of finding total number directories that contain files? there are about 14,000 directories some with files and some without....any help on this would be great...I am not sure if my commands are right so far....
thanks
camin


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Script to get disk usage per month.

shell script to get value of field www.computing.net/answers/unix/shell-script-to-get-value-of-field/6716.html

script to get the files created on recent sat www.computing.net/answers/unix/script-to-get-the-files-created-on-recent-sat/8422.html

Shell script to get the files by range www.computing.net/answers/unix/shell-script-to-get-the-files-by-range/8413.html