User storage report in Linux
-
Here is my way of doing it with Perl.
#!/usr/bin/perl printf "Generating overview over user account storage amounts..\n\n"; opendir(DIR, '/home/'); @dirs = readdir(DIR); closedir(DIR); foreach $dir (@dirs) { if($dir ne '..' && $dir ne '.') { $dir_size = `du -h --max-depth=0 /home/$dir`; $dir_size =~ s/\s.*//; printf "$dir : $dir_size"; } } printf "\n";
Put code in a file and chmod 755 to it to run as either console command or through a website.
To show through a website you can use something like this.
#!/usr/bin/perl
$output = `cat /home/myuser/scripts/thescript.pl`;
print "Content-Type: text/html\n\n";
print '<pre>'. $output .'</pre>';
Here is how the output looks like
root@Mybox adminscripts # ./userstorage
Generating overview over user account storage amounts..User1 : 608K
User2 : 28M
User4 : 300M
MyUser : 400Kroot@Mybox adminscripts #
Leave a Reply
Welcome to Thronic.com
Search this Site
Miscellaneous Links
Recent Articles
- Google-like search suggestion tool
- Linux Bash Color
- Resize a div layer with javascript
- Moving a div layer with javascript
- Web Galaxy » A sci-fi browser game
- Windows 7 on Asus Eee 900 PC
- IE and PHP sessions
- Wordpress 2.8.6 Spell Check Languages
- Reset MySQL Root Password
- Linux hosts file
- IdleGuard
- Column count in SQL
- String encryption in PHP
- Alphanumeric Captcha values in PHP
- Your own numeric Captcha in PHP
