Use shell to check for errors in logs and send emails if any errors occur.

Source: Internet
Author: User
Tags erro

#! /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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.