Page 1 of 1
Quota total Linux help
Posted: Mon Nov 22, 2010 6:03 pm
by domz
]So I am writing a php script and I need to find the total diskspace of a directory. I have used space already. I have a couple of different users with quotas
Code: Select all
$path = "/home/" . ($_SERVER['PHP_AUTH_USER']);
$used = exec("du -c -a $path");
echo $used;
Will give me the disk space used. But I need total quota for that user.
Maybe something with repquota /home
Re: Quota total Linux help
Posted: Mon Nov 22, 2010 8:27 pm
by domz
For example,
When I type in, #repquota /home
I get
Code: Select all
# repquota /home
*** Report for user quotas on device /dev/sda2
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 76 0 0 16 0 0
user1 -- 36400552 62914560 63488000 100 0 0
user2 -- 4 62914560 63488000 1 0 0
user3 -- 43955196 115343360 116367360 573 0 0
user4 -- 4 36700160 36864000 1 0 0
user5 -- 4 36700160 36864000 1 0 0
user6 -- 11724064 115343360 116367360 273 0 0
user7 -- 44976376 115343360 116367360 80 0 0
user8 -- 16223188 62914560 63488000 248 0 0
user9 -- 8073520 36700160 36864000 78 0 0
user10 -- 4878312 36700160 36864000 9 0 0
user11 -- 24 36700160 36864000 7 0 0
But I want to get get the hard quota for each user... Example User 1: I would do #repquota /home | grep user1
Code: Select all
repquota /home | grep user1
user1 -- 36400552 62914560 63488000 100 0 0
Now I want PHP to grab the Hard which is 63488000 (because that is the total disk quota).
Re: Quota total Linux help
Posted: Tue Nov 23, 2010 9:10 am
by Celauran
I don't have quotas in place on my machine, so I can't test this, but couldn't you call something like shell_exec("repquota /home | grep " . $something), explode on delimiter, and grab the necessary info from the nth position in the array?