Re: Re: Calculate Directory Size

From: Date: Sat, 26 Jan 2002 16:02:23 +0000
Subject: Re: Re: Calculate Directory Size
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-82221@lists.php.net to get a copy of this message
I'm sorry, but I won't be much help on the windows side of things, but for UNIX, the job is already done for you! There is a utility called 'du', which will tell you the disk usage of a file (or a folder and its contents). Specifically, you would want to use the -s flag to specify only to show the grand total, and not the size of each file... type 'du --help' or 'man du' at the command line to find out more. But an example: du -s -m /path/to/users/home/dir/ that will tell you in MB how much disk space they are using. Careful though, this is checking all their files recursively, so this can get cpu/hdd intense if you are using it for lots of users. My advice would be to run your script when there is a low load on the server. I hope that helps get you started. Jeff > Simon H <simon.hamilton@ntlworld.com> wrote in message > > news:ABEOLCLBKCFMEMHDPKLMIEIKCJAA.simon.hamilton@ntlworld.com... > > On advice, I've moved this from the Pear list. I have a > > problem...hopefully someone can help, because I've no idea where > > to even start! > > > > I have a user database, with a table called Users, and fields as so: > > > > (it would be cool if this would work on both Linux and Windows) > > > > ------------------------------------------------------------- > > User DiskUsage (Mb) Quota (Mb) HomeDirectory > > ------------------------------------------------------------- > > jim 50 100 F:\users\jim \\ In Windows > > > > jim 50 100 /users/jim \\ In Linux > > ------------------------------------------------------------- > > > > > > The database wouldn't be shared between Windows and Linux, just 1 or the > > other. > > > > What I would like to be able to do is, press a button on a php page, and > > scan the (MySQL or ODBC through Pear DB) database, and for each user, > > calculate the size of their HomeDirectory, and Update the DiskUsage in the > > DB accordingly. > > > > I'm wondering tho how this would work with say 1000's of users each with > > several hundred Mb's or even several Gb's each. The users will have > > subfolders too, so the function would have to recurse the dirs, if > > possible. > > > > Is this even possible with PHP? > > > > I appreciate any help I can get on this, because its waaaaaay beyond me > > presently. > > > > Thanks > > > > Simon H > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#82221) next »