- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Calculating file usage
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 04:05 AM
01-08-2003 04:05 AM
I'm currently on a project to migrate an old K-class server to an NT box (I know - I wasn't impressed either). One of the filesystems is 117GB in size and I have been asked to get all files over 6months old, calculate how much space they all take up and then do it on a per user basis.
I have done a find /myfs -mtime +168 -exec ll {} \; > list.
What I wanted to do was add each of the size fields together ($5) which i attempted in a 'for' loop this has worked but tells me I can get rid of 88GB! This may be true but I want to check whether my figures are correct and also get suggestions on an easier/better way of doing this. Advice would also be appreciated for getting the amount each individual user is using.
Thanks in advance,
Ton
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 04:20 AM
01-08-2003 04:20 AM
Re: Calculating file usage
TOTAL=`awk '{print (s+=$5/1073741824}' $FILENAME | tail -1
A bit shorter if nothing else.
(the 1073741824 is 1024*1024*1024)
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 04:23 AM
01-08-2003 04:23 AM
Re: Calculating file usage
I ran a quick test and it came up with 5 when my manual calculations came up with 5.9 GB. I think I'd save the division for the end - it looks like it's rounding. In other words, eliminate the
(( i = (i / 1024) /1024)) line
and divide by 1024 again in the
GB=$(expr $TOTAL / 1024) line.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 04:26 AM
01-08-2003 04:26 AM
Re: Calculating file usage
Try find /myfs -type f -atime +168 -exec du -k {} \; > list
Regards,
Jerome
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 04:26 AM
01-08-2003 04:26 AM
Re: Calculating file usage
It only deals in integers.
expr 10 / 3
3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 05:04 AM
01-08-2003 05:04 AM
Re: Calculating file usage
Try this script:
TOTAL=0
SIZES=`find /myfs -mtime +168 -exec ll {} \;|awk '{ print $5 }'`
for SIZE in SIZES
do
TOTAL=`expr $TOTAL + $SIZE`
done
echo "Total Size: $TOTAL Bytes"
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 05:22 AM
01-08-2003 05:22 AM
Re: Calculating file usage
Any thoughts on calculating it per user? This is what I have so far but it seems to product differing results (e.g 5user in a row have the same space then 1 has 17GB!?)
Cheers,
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 09:49 AM
01-08-2003 09:49 AM
Re: Calculating file usage
Here's a VERY simple "perl" program:
#!/opt/perl/bin/perl
$SYMBOLS=" KMGTP";
$totarr="";
while (<>) {
tr/ / /s;
($tmp1,$tmp2,$username,$grpname,$filesize,$tmp3) = split(/ /);
if ($username ne "") {
$totarr{$username} += $filesize;
}
}
foreach $username (sort keys %totarr) {
$filesizes=$totarr{$username};
$spaceinuse=0;
$spacesymbol="";
for ($i=0;$i < 6;$i++) {
if ($filesizes >= (1024**$i)) {
$spaceinuse=$filesizes/(1024**$i);
$spacesymbol=substr($SYMBOLS,$i,1);
}
}
printf("%9s %15.3f %sB, bytes is %s\n",$username,$spaceinuse,$spacesymbol,$totar
r{$username});
To use it, do something like this:
perlprogram.pl < yourfilelist
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2003 10:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2003 03:35 AM
01-09-2003 03:35 AM
Re: Calculating file usage
Thanks for that - a good platform for me to start learning perl. I look forward to when I can call that VERY simple :) Thanks to everyone for your responses.
cheers,
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2003 03:58 AM
01-09-2003 03:58 AM
Re: Calculating file usage
With my limited Perl knowledge I set about editing your script so that it would just produce the total amount of space taken up by all the files. The result is 152GB which I know cannot be right! Could you point me in the right direction?
Thanks,
Tony