Hi,
I am trying to write a shell script to monitor file changes in Red hat linux but had some problems.
=============filemod.sh=========================
#!/bin/bash
dir=/
freq='-1'
email=me@domain.com
udate=`date +%y-%m-%d`
utime=`date +%H:%M`
check=`find $dir -mtime $freq -type f -exec ls -lh {} \;`
count=`cat $check | wc -l`
if [ $count -gt 0 ]
then
sub="Attention! $count File Modified on $udate at $utime"
echo `cat $check` | mail -s "$sub" $email
else
echo "no files were modified on $udate at $utime
fi
fi
I have problems to execute the script. Can someone please optimize it or correct it. I need this report should email on dialy basis for every day (so may be -1 should ok?) and also use cron for this
thanks
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.