May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

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>