Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux Daily Business order data Statistics

Shulou Source: shulou.com Published: 2022-06-02 13:03:09 09月30日 Update

Key points: sql feeds, source data statistics, html formatting, email delivery,

Execution compliance is not displayed due to blog format

#! / bin/bash

# xxxx Business processing Summary

Source / etc/profile # sqlplus client variables are configured

Export ORACLE_HOME=/home/middle/oracle12client

Export SQLPATH=/home/middle/oracle12client

Export TNS_ADMIN=/home/middle/oracle12client

Export NLS_LANG= "american_america.ZHS16GBK"

Export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH

Export PATH=$PATH:$ORACLE_HOME

TM1=date-d "- 1days" +% Y%m%d

TM2=date +% Y%m%d

TM3=date-d "- 1days" +% Y-%m-%d

Cd / home/middle/script/yewu

# clear the contents of the file (> do not show)

Order.txt

Sucess_order.txt

User_order.txt

User_sucess_order.txt

Jieguo.txt

Dbuser= "Database user name"

Dbpwd= "database password"

Dbserv= "Database name"

# mention # #

Sqlplus-s ${dbuser} / ${dbpwd} @ ${dbserv} = to_date ('$TM1','yyyymmdd')

And t.inserttime = to_date ('$TM1','yyyymmdd')

And t.inserttime = to_date ('$TM1','yyyymmdd')

And t.inserttime = to_date ('$TM1','yyyymmdd')

And t.inserttime > $qd_output

}

Function create_table_end () {

Echo-e ""

}

Function create_html_end () {

Echo-e ""

}

MAIL_LIST='xxxx@xx.cn'

NM=wc-l order.txt | awk'{print $1}'

NM=expr $NM + 1

Echo "business code, business name, business, total business, successful business, number of users, business, number of successful users" > jieguo.txt

If [$NM-ge 3]; then

For I in awk'{print $1} 'order.txt | grep-v PRODUCTID

Do

MC=grep-w $I taocan.txt | awk'{print $2}'

If [Unkonw_name$MC = "Unkonw_name"]

Then

MC=Unkonw_name

Fi

ZL=grep $I order.txt | awk'{print $2}'

ZL=expr $ZL + 0

SZL=grep $I sucess_order.txt | awk'{print $2}'

SZL=expr $SZL + 0

UZL=grep $I user_order.txt | awk'{print $2}'

UZL=expr $UZL + 0

USZL=grep $I user_sucess_order.txt | awk'{print $2}'

USZL=expr $USZL + 0

Echo "$I $MC $ZL $SZL $UZL $USZL" > > jieguo.txt

Done

# output content html email #

Create_html_head1 "Hello everyone, the business processing of ${TM3} xx is as follows:" > > $qd_output

Create_table_head > > $qd_output

While read line

Do

Echo $line

Create_tr "$line"

Done

< /home/middle/script/yewu/jieguo.txt create_table_end >

> $qd_output

Cat qd.html | mutt-s "${TM3} xxxx process summary"-e'set content_type= "text/html"'$MAIL_LIST

Else

Echo "Hello everyone, the total amount of $TM3 xxxx processing is: 0" | mutt-s "$TM3 xxxx processing total is: 0" $MAIL_LIST

Fi

Tags: Business business processing data total database format user success content number of users mail data statistics statistics code key key function blog variable name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Linux Redmi MySQL