Alert when file is modified in Linux

This is one of the script I used many years ago. There are many other methods now, but just thought of adding it.

I had a server where few files were modified by malware. I applied all security measures and in order to alert me in case file is modified again, I created below shell scripts and added to cron. This can be executed in every minutes or hour based .  Once file is created add it to crontab.

#!/bin/bash
[[ -z `find /home/user/public_html/ -mmin -60` ]] if [ $? -eq 0 ] then
echo -e “nothing has changed”
else
find find /home/user/public_html -mmin -60 -type f | mail [email protected] -s “Modified files on /home/user/public_html”
fi

facebooktwittergoogle_plusredditpinterestlinkedinmail

LEAVE A COMMENT