December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

List last modified – shell Script

SHORT_HOSTNAME=`hostname -s`
LOCATION="/home"
#
DESTINATION="$1"
if [ -z "$1" ]
then
  DESTINATION="$LOCATION"
fi
#
EMAIL_TO="test@rmohan.com"
EMAIL_SUBJECT="List Last Modified files from $SHORT_HOSTNAME"
EMAIL_BODY_Line1="Below is the list of last modified files:"
#
MOD_FILES=`find $DESTINATION -type f -mmin -10 -ls`
#
if [ -n "$MOD_FILES" ]
then
  printf "$EMAIL_BODY_Line1\n\n$MOD_FILES\n" | mail -s "$EMAIL_SUBJECT" $EMAIL_TO
fi
#

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>