当前位置:网站首页>Shell执行SQL发邮件
Shell执行SQL发邮件
2022-08-01 07:23:00 【代元培】
#!/bin/bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE-$0}")";pwd)
exec 1>>$CUR_DIR"/log/test.log"
exec 2>>$CUR_DIR"/log/test.log.wf"
. ~/.bashrc
# 脚本每月1号自动执行
# 本月第一天
nowdate=`date +%Y%m01`
# 上月第一天
syFirstDt=`date -d"$nowdate last month" +%Y%m%d`
#上上个月的最后一天
ssyLastDt=`date -d"$syFirstDt last day" +%Y%m%d`
# 上个月最后一天
syLastDt=`date -d"$nowdate last day" +%Y%m%d`
# 上月月份
sy=`date -d"$nowdate last day" +%Y%m`
# 执行时间记录
current=`date "+%Y-%m-%d %H:%M:%S"`
#timeStamp=`date -d "$current" +%s`
echo '[run time]' $current
#将current转换为时间戳,精确到毫秒
#currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000))
sql="select ..."
echo '[sql]' $sql
data=`echo -e ${sql} |testdb -t -A`
echo $data
ret=`echo -e $data |awk -F '|' '{print $4}' `
# 发邮件
title="${sy}执行结果为"
content="$title (${ret})"
echo $content | mail -s "${title}" [email protected] [email protected]
echo '*** shell done ***'边栏推荐
- Offer brush questions - 1
- crypto-js uses
- 第02章 MySQL的数据目录【1.MySQL架构篇】【MySQL高级】
- R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:gtExtras包的pad_fn函数与gt::fmt函数一起用于填充包含数值的特定列、对数据列的数值进行十进制对齐(从小数点对齐)
- Srping中bean的生命周期
- 搜索框字符自动补全
- sum of special numbers
- special day to remember
- pytest接口自动化测试框架 | 使用函数返回值的形式传入参数值
- pytest接口自动化测试框架 | 集成Allure测试报告
猜你喜欢
随机推荐
Golang: go to connect and use mysql
app 自动化 打开app (二)
并发编程13-JUC之CountDownLatch
return;代表含义
LeetCode240+312+394
上课作业(7)——#598. 取余运算(mod)
sum of special numbers
微信小程序请求封装
图像基本操作的其他内容
从零开始—仿牛客网讨论社区项目(一)
VoLTE基础学习系列 | 什么是SIP和IMS中的Forking
第02章 MySQL的数据目录【1.MySQL架构篇】【MySQL高级】
Go 支持 OOP: 用 struct 代替 class
Fist game copyright-free music download, League of Legends copyright-free music, can be used for video creation, live broadcast
Information system project managers must recite the work of the core test site (56) Configuration Control Board (CCB)
Vim简介
my creative day
Golang:go开启web服务
旋度(7)连接失败localhost8080;连接拒绝了
Datagrip error "The specified database userpassword combination is rejected..."Solutions









