Linux shell脚本 将数据库超时的订单号 发送给客服
来源:互联网 发布:怕死 陈奕迅 知乎 编辑:程序博客网 时间:2024/06/06 05:03
1、SHELL 脚本 将超时的数据库订单号(所有的) 发送给客服 实例:#!/bin/bash# Define log USERNAME="root"PASSWORD="xx"DBNAME="tgq_master" #数据库名称TABLENAME="appraisal_apply" #数据库中表的名称#查询select_sql="SELECT order_sn as '订单号' from ${TABLENAME} a where a.status = 1 AND a.apply_time < unix_timestamp(now())-(select value from config where name='appraisal_time_limit')*60"mysql -u${USERNAME} -p${PASSWORD} ${DBNAME} -e "${select_sql}" > overtimeorder.txtnum=$(cat overtimeorder.txt |wc -l)if [ $num -gt 1 ]then#echo "这是超时的订单号,请及时处理!" >> overtimeorder.txtmail -s "这是鉴宝超时的订单号,请及时处理!" 429756472@qq.com < overtimeorder.txtelse echo "what?"fi2、发送实时订单号 #!/bin/bash# Define log 默认订单超过xx分钟发给客服#写入日志文件TIMESTAMP=`date +%F_%H:%M:%S` #LOG=call_sql_${TIMESTAMP}.log LOG=call_sql_shell.log echo "Send order_sn Start select sql statement at ${TIMESTAMP}." >>${LOG}#数据库信息USERNAME="root"PASSWORD="xxxxx"DBNAME="tgq_master" #数据库名称TABLENAME="appraisal_apply" #数据库中表的名称#查询select_sql="SELECT order_sn as '订单号' from ${TABLENAME} a where a.status = 1 AND a.apply_time < unix_timestamp(now())-(select value from config where name='appraisal_time_limit')*60"mysql -u${USERNAME} -p${PASSWORD} ${DBNAME} -e "${select_sql}" > overtimeorderall.txt#比较两个文件的不同之处 并赋予新文件#找出a.txt文件有而b.txt文件中没有的放在c.txt文件中comm -23 overtimeorderall.txt overtimeorderold.txt > overtimeordernew.txtcomm -23 overtimeorderall.txt overtimeorderold.txt >> overtimeorderold.txt#查询最新超时订单号文件 的行数num=$(cat overtimeordernew.txt |wc -l)#行数大于0 存在则发送邮件 不存在写入日志文件if [ $num -gt 0 ]then#发送邮件mail -s "这是鉴宝超时的订单号,请及时处理!" 429756472@qq.com < overtimeordernew.txtecho "send email"else echo "Database has no relevant data! at ${TIMESTAMP}." >>${LOG}fi
0 0
- Linux shell脚本 将数据库超时的订单号 发送给客服
- linux发送邮件的shell脚本
- linux shell 脚本程序:将时间赋给变量
- Linux Shell脚本发送邮件
- linux shell 脚本/命令 超时 结束
- 通过C++和shell脚本去解析URL && c++调用shell脚本后将脚本的内容返回给程序
- shell脚本 给linux上的用户群发信息
- shell脚本超时控制
- shell脚本超时控制
- shell脚本超时控制
- shell脚本超时watchdog
- Linux下将awk的变量赋值给shell变量
- linux通过shell脚本发送网络邮件
- linux shell脚本 变量给变量赋值
- linux的shell脚本
- 如何将c语言的变量传递给shell脚本使用
- MySQL :: Linux 下自动备份数据库的 shell 脚本
- Linux下定时备份MySQL数据库的Shell脚本
- bzoj3809Gty的二逼妹子序列 莫队+分块
- Redis Jedis的使用(下)
- strcpy_s与strcpy的比较
- Android 静态字符串安全存储方案
- HEARTBEAT+DRBD+NFS 高可用共享搭建
- Linux shell脚本 将数据库超时的订单号 发送给客服
- Not so Mobile UVA
- 设计模式-代理模式
- Candence16.6打开文件的问题
- vua 1660 Cable TV Network 最大流最小割 求割点
- 从宏函数到内联函数
- java中空串""与null的区别与判断
- HDOJ 5410 01背包+完全背包
- c++第二天