Script to compare crontabs
Hi I Need a script to monitor the cron entries and if there is any change in the crontab entry it needs to alert me.
For this I have used the method by taking a copy of current crontab then it needs to compare the crontabs every day.If there is any alteration found it needs to alert me.Is this possible? I first Copied my current crontab using "crontab -l>cron.txt" then by "crontab -l > $(date +%Y%m%d).crontab" took a copy by date and day wise but I dont know how to compare this files in aregular manner and send mails if it found alteration.. |
Ok, so what have you written so far?
|
Quote:
CHECKF=/tmp/last.crontab.check ALERT=iam@userhost if [ -f $CHECKF ] then find $CRDI -type f -newer $CHECKF | while read tabfile do echo "Crontab file for user $(basename $tabfile) has changed" | mail -s "Crontab changed" $ALERT done fi touch $CHECKF will this script fit for my above requirement? |
Why don't you just compare the md5 values of the crontab vs a standard? If they don't match, you send an email. You could store all the standard md5 values in a restricted access file. Seems a bit safer to me than relying on system dates.
|
All times are GMT -5. The time now is 12:54 PM. |