ratna1234
asked on
Shell Script
ls -lrt MMMM_APPS.log
MMMM_APPS.log
Based on last log file time if the log file is not updated more than 30 min , i need to send an mail that "Log file is no updated past 30 Min".
MMMM_APPS.log
Based on last log file time if the log file is not updated more than 30 min , i need to send an mail that "Log file is no updated past 30 Min".
What *nix flavour will this be running on?
ASKER
Its Linux
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
In my code 4th line $file is the full path of file MMMM_APPS.log.
Anyway let us know the update.
Thankxx
In my code 4th line $file is the full path of file MMMM_APPS.log.
Anyway let us know the update.
Thankxx
put this following code in a file and save it like :/home/ratna/mmmm_alert.sh
Script start:
#!/usr/bin/sh
current=`date +%s`
last_modified=`stat -c "%Y" $file`
if [ $(($current-$last_modified
echo "Log file is no updated past 30 Min" | mail -s "MMMM_APPS.log not updated" <desired mail address>
else
exit
fi
--------------------------
Now add this file to crontab for run every 30 min -
0,30 * * * * /home/ratna/mmmm_alert.sh
Thankxx