shell 访问mysql 并定时执行增删改查

vim filterData.sh


result_time=`date -d "today" +"%Y%m%d"`

result_file=/home/gree/msa/yw_msa/sheeldLogic/log/${result_time}_result_sheeldLogic.log

mysql -h 10.2.5.52 -uname -ppwd -e"use g_details;

delete a.*from t1 a,(select id,pdate from t2 where pdate<\"2018-09-01 00:00:00\" )b where a.ename in (\"name1","name2\")

and a.id=b.id;

delete a.* from t1 a inner join(select id,pdate from t2 )b where a.ename in (\"name1","name2\") and b.pdate<\"2018-09-01 00:00:00\" and a.id=b.id; "


echo "mysql_ok">>${result_file}
`date -d "today" +"%Y-%m-%d %H:%M:%S"`>>${result_file}
# mysql 每天按需求删除数据(每60分钟删除一次)
crontab -e
*/60 * * * * sh /home/ge/msa/yw_msa/mysql_producedate_filter/filterData.sh
#每个整点执行1次
0 */1 * * * sh /home/ge/msa/yw_msa/mysql_producedate_filter/filterData.sh

#每3个整点执行1次
0 */3 * * * sh /home/ge/msa/yw_msa/mysql_producedate_filter/filterData.sh
               
           分  时 天 月 星期     
每五分钟执行  */5 * * * *

每小时执行     0 * * * *

每天执行        0 0 * * *

每周执行       0 0 * * 0

每月执行        0 0 1 * *

每年执行       0 0 1 1 *

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值