Someone is using a lot of space, and you want to find out who. More specifically, you would like to identify the large files and automatically send them an email about it.
This script will do that for you. It’s called findbig, and can be called by hand or from a cron job. It will only send one email to a user, with a list of all large files in it. It sends mail to the local user account, if you want the user’s mail sent to a different address, you will have to either edit the file or use the /etc/aliases file to redirect the email.
The parameters are:
findbig [ - a age ] [ -c ] [ -m addr ] [ -l log ] [ -u ] [ -d ] [ -s size ] [-e dir] [-x filename] [dir [size] ]
-a age Minimum age, in days -c console mode, echo all messages to screen -d Debug mode -s size Minimum size of files to report -e dir Directory to exclude -m addr Email address to send all messages to -l log Append results to this file -u Send mail to owner -x filename filename containing directories and files to exclude. The file contains one path or file per line. Directories are identified by a trailing slash Comments begin with a pound sign (#)
dir Directory or file to work on size Minimum size of files to report. Suffixes are allowed (k for K, m for meg, g for gig, t for tera). Both lower and upper case are allowed
An example (broken up onto 2 lines):
findbig -a 10 -m email@example.com -e /var/lib/libvirt/images \ -e /proc -l /home/jbayer/bin/test.log -u / 10g
And this does the following:
- Send emails to me of found files
- Send emails to the owner of the file
- Exclude the following directories:
- Log results in the file /home/jbayer/bin/test.log
- Start in the / directory
- Find all files bigger than 10 gig in size, and at least 10 days old
findbig.tar.gz (2.2 KiB, 384 hits)