1.配制mail
hosts第二列要为全域名.
bash-3.00# less /etc/hosts
#
# Internet host table
#
::1 localhost
127.0.0.1 localhost
192.168.195.61 mdc-solsvr.org mdc-solsvr loghost
192.168.203.61 mdc-yz.org mdc-yz
确认sendmail服务在enable状态,如是disable请开启服务(mailx需调用sendmail来发信)
svcadm enable sendmail
-bash-3.00$ svcs -a|grep mail
online 9月_21 svc:/network/smtp:sendmail
2.脚本
-bash-3.00$ cat SendOperAccMonth.sh
#!/bin/bash
source /export/home/oracle/.profile
#date=`date '+%Y-%m-%d'`
fromaddr='qhchen_auto_acc@mdc.cn'
toaddr='qhchen@mdc.cn,yfxu@mdc.cn'
sdate=`sqlplus -s mdc/mdc@wxdb < alter session set nls_date_format='yyyymmdd hh24:mi:ss';
select trunc(last_day(add_months(sysdate,-2))+1) " " from dual;
exit
EOF
`
sdate=`echo $sdate | nawk '{print $4}'`
odate=`sqlplus -s mdc/mdc@wxdb < alter session set nls_date_format='yyyymmdd hh24:mi:ss';
select trunc(sysdate-1) " " from dual;
exit
EOF
`
odate=`echo $odate | nawk '{print $4}'`
wx=`sqlplus -s mdc/mdc@wxdb < select count(*) " " from operatorcalldata
where begintime between trunc(last_day(add_months(sysdate,-2))+1) and trunc(sysdate) and operatorno like '0%';
exit
EOF
`
yz=`sqlplus -s mdc/mdc@yzdb < select count(*) " " from operatorcalldata
where begintime between trunc(last_day(add_months(sysdate,-2))+1) and trunc(sysdate) and operatorno like '0%';
exit
EOF
`
sz=`sqlplus -s mdc/mdc@szdb < select count(*) " " from operatorcalldata
where begintime between trunc(last_day(add_months(sysdate,-2))+1) and trunc(sysdate) and length(caller)>10;
exit
EOF
`
echo -e $sdate--$odate"\n"无锡:$wx"\n"扬州:$yz"\n"苏州:$sz | mailx -r $fromaddr -s "月话务量统计$sdate-$odate" $toaddr
阅读(978) | 评论(0) | 转发(0) |