• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

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".
0
ratna1234
Asked:
ratna1234
  • 2
  • 2
1 Solution
 
ThankxxCommented:
Hi,
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)) -gt 1800 ]; then
    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

0
 
TintinCommented:
What *nix flavour will this be running on?
0
 
ratna1234Author Commented:
Its Linux
0
 
TintinCommented:
In that case


#!/bin/bash
if [ -z "$(find /some/path -name "*APPS_LOG" -mmin -30)" ] 
then
   echo | mail -s "Log file is not updated past 30 Mins" spme@address
fi

Open in new window

0
 
ThankxxCommented:
Hi,
In my code 4th line $file is the full path of file MMMM_APPS.log.
Anyway let us know the update.

Thankxx
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now