Scripts for users who use too much space..
Rusty Carruth
plug-discuss@lists.PLUG.phoenix.az.us
Sun, 27 May 2001 05:23:43 -0700 (MST)
>
> Funny I have been doing something similar:
>
> find /home -size +100000 -xdev -printf '%u\t%b\t%AD\t%h/%fd\n' | sort
>
> Then just send the user an email, but I wanted something a little more
> automated..
>
cron is your friend.
cat >new.crontab <<ENDEND
01 0 * * * * find.and.notify.hogs
ENDEND
cat > space.hog.notice <<ENDEND
Greetings, space hog. You've got some bad stuff out there - please
clean it out! Here's the list:
ENDEND
cat > find.and.notify.hogs <<ENDEND
#!/bin/bash
find /home -size +100000 -xdev -printf <etc>' | sort > /tmp/fanh.$$
cat /tmp/fanh.$$ >> space.hog.notice
for u in `awk '{print $1}' /tmp/fanh.$$ |sort | uniq ` ; do
elm $u -s "Space hog alert" < space.hog.notice
done
cat >home.hog.notice <<ENDEND
Greetinsg. Your home dir is getting a bit weighty.
Please put it on a diet! Here you are:
ENDEND
du -sk /home/* | awk '{if ($1 > 100000) { print};};{continue};' > /tmp/fanh.homes.$$
cat /tmp/fanh.homes.$$ >> home.hog.notice
for u in `awk '{print $2 }' /tmp/fanh.homes.$$ ` ; do
elm $u -s "Home hog alert" < home.hog.notice
done
- season to taste ;-)
(Warning - the above was typed in without runnin it through the shell,
there are probably errors - but you get the idea ;-)
rc