Shell 定时更新数据库功能

1.定时更新数据库功能

#!/bin/sh

i=1;
while(($i<100));do
        dateTime=$(date +'%Y-%m-%d %H:%M:%S')
        sql="update mytable  set gmt_created='$dateTime' where custins_id >= 123971  and custins_id<= 123981;"
        #将sql内容写入文件中
        echo $sql > sql
        #从文件中执行SQL
        $(mysql -umytest -pmytest -hlocalhost -P3306 mytest < sql)
        sleep 1800
done