Dear All,
My server is running crontabs of 4 different users.
I want to develop a script that whenever a particular change occurs in a crontab , it is detected and the particular change is noted into a file.
Kindly let me know of suggestions on how it can be achieved.
My algo would be:
- Make a copy of the file
- Compare present crontab to copy.
- Use diff to comapre both files.
- If change present subtract new file from old one and extract the difference.
Regards
---------- Post updated at 12:05 PM ---------- Previous update was at 10:01 AM ----------
DIFF=`comm -13 /var/spool/cron/crontabs/jun /var/tmp/temp_crontabs/jun_temp`
#DIFF=`comm -13 /var/tmp/temp_crontabs/jun_temp /var/spool/cron/crontabs/jun`
if [ "$DIFF" == "" ]
then
echo "======================"
echo "No change in crontab"
echo "======================"
else
echo "$DIFF"
echo "$DIFF"|mailx -s "Crontab Change Alert" my-email@id.com
fi
cp /var/spool/cron/crontabs/jun /var/tmp/temp_crontabs/jun_temp
This is what Ive done till now but its not giving me the proper result.