#! /Bin/bash
# Initializing Environment Variables
Source. bash_profile
# Inherent date format in log name
F_name = 'date + % Y % m % d'
# Log path and name
LOG_FILE =/backup/DB/RMAN/log/RMAN $ f_name-0401.log
Echo $ LOG_FILE
# Counting the number of log files
# Line_num = 'wc-L $ LOG_FILE | awk '{print $1 }''
# Echo $ line_num
# If the log file does not exist, send an email directly. Otherwise, check whether the file contains the erro and erro keywords. If yes, send an email.
If [! -E $ LOG_FILE]
Then
Echo "send mail"
Echo "File $ LOG_FILE not found" | mutt-s "An error occurred while backing up the Bi database RMAN" -- [email protected]
Else
Erro_num = 'cat $ LOG_FILE | grep 'erro '| WC-l'
Erro_num = 'cat $ LOG_FILE | grep 'erro '| WC-l'
If [$ erro_num-GT 0-o $ erro_num-GT 0]
Then
Echo "send mail"
Echo "check the file $ LOG_FILE" | mutt-s "Bi database RMAN backup error" -- [email protected]
Fi
Fi
This article is from the "Linux" blog, please be sure to keep this source http://linuxengineer.blog.51cto.com/7391710/1440330
use shell to check whether there are errors in the log, and send an email if there are any errors