Periodically counts a certain amount of data and sends out the statistical results by mail.

Source: Internet
Author: User

Periodically counts a certain amount of data and sends out the statistical results by mail.

The statistical results are automatically sent by mail, and mutt is used. The installation of mutt is simple: yuminstallmutt, which can be used after installation.

Mutt is really a good thing. It can send emails without starting sendmail or postfix, and it is much better than the built-in mail.

In linux5, The mutt syntax is:

Echo "hello" | mutt-atest.txt-s "date" admin@test.com

Subject recipient of the body attachment

The mutt syntax in linux6 is

Echo "hello" | mutt-atest.txt-s "date" -- admin@test.com

Subject recipient of the body attachment

View mutt help: mutt-h

Modify the sender information (to avoid using the root @ host name. host domain name as a spam email)

Under the user who needs to send an email

Create the following files

Vi ~ /. Muttrc

Setenvelope_from = yes

Set

Setrealname = "yourname"

Setuse_from = yes

# If the received email is garbled, set the following information:
Setcharset = "UTF-8"
Setrfc2047_parameters = yes

The stored procedure of regular statistics is omitted.

The following is a script to automatically generate statistical results using shell:

#! /Bin/bash
Source/home/oracle/. bash_profile
Cd/home/oracle/zhangwz/
Rm-rflog

Sqlplus-szhangwz/****** <EOF> log
Setfeedoff

-- Execute the process and put the result in the table losscall.
Execp_losscall;
--Put the losscallresult in 1.txt
Setlines400;
Setpages9000;
Spool1.txt
Selectrownumsn, losscall. * fromlosscall;
Spooloff;
Exit
EOF

Filename = 'date + % Y % m % d-% H % m'
Sed'1d'1.txt> $ filename.csv
Rm-rf1.txt

Hour = 'date | cut-c18-20'
If [$ hour-eq9]
Then
Echo "XX, hello:
The appendix is the call loss phone number from yesterday to today. "| Mutt-a%filename.csv-s" call loss phone "zhangwz@xx.net
Elif [$ hour-eq13]
Then
Echo "XX, hello:
The appendix is the call loss number from. "| Mutt-a%filename.csv-s" call loss phone "zhangwz@xx.net
Else
Echo "XX, hello:
The appendix is the call loss number from. "| Mutt-a%filename.csv-s" call loss phone "zhangwz@xx.net
Fi

Rm-rf *. csv

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.