Monitoring of changes in files at linux

I have got this script here:



ulimit -t 20
checkdir="/bin /sbin"

exec 2>&1
umask 266
find $checkdir -type f -printf "%m\t" -exec md5sum {} \; >$filedb.tmp
diff $filedb $filedb.tmp
mv -f $filedb.tmp $filedb
if [ "$out" ];then 
 (date; echo; echo "$out") | mail -s "Change permsec `hostname`" $email fi

This script is checking all files in folders from “checkdir” variable, calculating their MD5 hashes, writing results to file “filedb” and compares it with results of last checking by “diff” program. If differences found then script sending email message to If results are identical then nothing hapens. Script needs to be launched periodically by “cron” program.

Leave a Reply

Your email address will not be published. Required fields are marked *

Protected by WP Anti Spam