troubleshooting Question

Linux shell script to monitor changed files

Avatar of luser9999
luser9999 asked on
Linux
10 Comments1 Solution1111 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros