#40 Reporting Disk Hogs

Most system administrators seek the easiest way to solve a problem, and the easiest way to manage disk quotas is to extend the fquota script, Script #39, to include the ability to email warnings directly to users who are consuming too much space.

The Code

 #!/bin/sh # diskhogs - Disk quota analysis tool for Unix; assumes all user # accounts are >= UID 100. Emails message to each violating user # and reports a summary to the screen. MAXDISKUSAGE=20 violators="/tmp/diskhogs0.$$" trap "/bin/rm -f $violators" 0 for name in $(cut -d: -f1,3 /etc/passwd | awk -F: '$2 > 99 { print $1 }') do echo -n "$name " # You might need to modify the following list of directories to match # the layout of your disk. Most likely change: ...

Get Wicked Cool Shell Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.