Alert when z file on linux server has been changed by x user.
#/bin/sh
old_time=`stat -c %z /var/spool/cron/root`
if [[ "$new_time" != "$old_time" ]];
then
echo -e "Changes has been made in Cron file" | mail -s "Modification alert" abhinav.dixit@xyz.com
echo -e "$old_time"
echo -e "$new_time"
else
echo "no change"
fi
Actually i want to track the user who make any change in z file where z file is accessed by n number of users. I am trying with above script atleast to get an alert when z file is changed. I have no idea how to track which user has changed it.