HOST_NAME='127.0.0.1'
DB_PORT='3306'
DB_NAME='數據庫名'
USER_NAME='root'
PASSWD='root'mysql
TIME=$(date '+%s')linux
MYSQL_ETL="mysql -h${HOST_NAME} -P${DB_PORT} -u${USER_NAME} -p${PASSWD} ${DB_NAME} -s -e"
hive_table_sql="select user_id from mx_user where token_time >0 and online=1 and token_time <= ${TIME}"
hive_table=$($MYSQL_ETL "${hive_table_sql}")sql
for userid in $hive_table
do
此處邏輯處理(我這裏的例子是查出再修改)
update_sql="update mx_user set online=0 where user_id=${userid}"
$($MYSQL_ETL "${update_sql}")
doneshell