Hi,
Here is the script that I have written to check if a particular user is has logged out, and if yes, then a mail needs to be sent to the management the details of whatever has been captured by the script command.
echo "The current users are:"
who | awk '{print $1}' | sort > temp1
cp temp1 temp2
more temp1
while true
do
who | awk '{print $1}' | sort > temp2
cmp -s temp1 temp2
case "$?" in
1)
user="absprod1"
file=`grep $user temp1 temp2 | cut -c 1-5`
echo $file
file1=`echo $file | cut -c 1-5`
echo $file1
if [ $file1 = "temp1" ]
then echo "User "$user" has logged out." | mail -s "Logged out"
abc@xyz.com
cat /home/absprod1/test_audit | mail -s "Audit report"
abc@xyz.com
fi
esac
rm temp1
mv temp2 temp1
rm /home/absprod1/test_audit
return
done
My question is how to have this script executed continuously so that, it captures every logout of the user id absprod1? Can anyone please help me?