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