#SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY.
MYPATH="/clocal/mqbrkrs/user/sanjay/"
MAIL_RECIPIENTS="abc@def.com"
Subject="File accessed in last few minutes are ::"
>tempmail.txt
>tempfind.txt
## List all the files which one accessed since last 1 min #####
for file_dir in `find $MYPATH -amin -1`
do
### Find out the PID for that files which one been accessed
pids = ''
#fuser -f "$file_dir" > tempfind.txt
#pid=$(tr -dc "[:digit:]\n" < tempfind.txt)
pids=`fuser -f "$file_dir" | tr -dc "[:digit:]"`
echo "$pids"
### Find out the owner/user name for that Process
### Replace the $access_user_filed with the filed no from the ps -ef
### command
user = `ps -ef | grep -w "$pid" | awk '{ print $1 }'`
echo " $file_dir access by the $user " >> tempmail.txt
done
cat tempmail.txt | mailx -s "$Subject" "$MAIL_RECIPIENTS"
Prblem is, I am not getting o/p in tempmail.txt file.
Please guide me on this !!
Thanks in advance !!
