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

Source: Internet
Author: User
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. The mutt syntax in linux5 is echo & quot; hell

The statistical results are automatically sent by mail, and mutt is used. The mutt installation is simple: yum install mutt, 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-a test.txt-s "date" admin@test.com

Subject recipient of the body attachment

 

The mutt syntax in linux6 is

Echo "hello" | mutt-a test.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

Set envelope_from = yes

Set

Set realname = "yourname"

Set use_from = yes

# If the received email is garbled, set the following information:
Set charset = "UTF-8"
Set rfc2047_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-rf log

Sqlplus-s zhangwz/****** <EOF> log
Set feed off

-- Execute the process and put the result in the table losscall.
Exec p_losscall;
--Put the losscallresult in 1.txt
Set lines 400;
Set pages 9000;
Spool 1.txt
Select rownum sn, losscall. * from losscall;
Spool off;
Exit
EOF

Filename = 'date + % Y % m % d-% H % M'
Sed '1D '1.txt> export filename.csv
Rm-rf 1.txt

Hour = 'date | cut-c 18-20'
If [$ hour-eq 9]
Then
Echo "XX, hello:
The appendix is the call loss phone number from yesterday to today. "| Mutt-a fill filename.csv-s" call loss phone "zhangwz@xx.net
Elif [$ hour-eq 13]
Then
Echo "XX, hello:
The appendix is the call loss number from. "| Mutt-a fill filename.csv-s" call loss phone "zhangwz@xx.net
Else
Echo "XX, hello:
The appendix is the call loss number from. "| Mutt-a fill 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.