#!/bin/sh
if [ -e /var/log/mail -a -r /var/log/mail ]
then
for x in `cat usernamefile`
do
grep $x /var/log/mail > /log/usermail
done
fi
this will give you a log of all user activity.
The usernamefile is just a text file containing the names of your users.
If you have tons of users and don't feel like
writing a file that large you can write something like this to filter your password file and generate names if you have reasonable UID ranges.
awk -F":" $3 < 600 && $3 > 499 {print $1}' >
usernamefile-your own ranges would be applicable of course
If you want to get a little pickier you can
just add
grep "username" /log/usermail > /log/usrname
before the end of the for loop. You could add the awk to the script so that a new list is generated every time you add users and run the script. Just put it before the test(if).
Then you schedule this via cron.
If you want something a little fancier, you can sort and sed your way through it, or
check out the awk forum.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.