sh角本操作数据库

#!/bin/bash

HOST="127.0.0.1"
PORT="3306"
USERNAME="root"
PASSWORD="123456"
DBNAME="fofapro"



#定时修改
update_sql="
update enterprise_ip_tasks set state = 'failure',updated_at = DATE_FORMAT(NOW(),'%Y-%m-%d %T') where id in (
  SELECT * FROM (
    (SELECT id FROM enterprise_ip_tasks where TIMESTAMPDIFF(MINUTE,created_at,DATE_FORMAT(NOW(),'%Y-%m-%d %T')) >=20  and user_id in (100063403) and result_file = '' and state = 'init') 
  as t
 )
);
"
mysql -h${HOST}  -P${PORT}  -u${USERNAME} -p${PASSWORD} ${DBNAME} -e "${update_sql}"


[Haima的博客] http://www.cnblogs.com/haima/
posted @ 2021-06-12 22:34  HaimaBlog  阅读(19)  评论(0编辑  收藏  举报