The main application of the shell for loop
Define the database connection information
= HOST_NAME '127.0.0.1'
DB_PORT = '3306'
the DB_NAME = 'database name'
USER_NAME = 'the root'
the PASSWD = 'the root'
TIME current timestamp $ () Note date is the middle of a space
TIME=$(date '+%s')
-s remove header
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}")
for variable in isolated data, and then traverse the variable done deal
$ hive_table in the userid for
do
here logic (I example here is isolated modify)
update_sql = "Update mx_user Online SET = 0 WHERE user_id the userid = {} $"
$ ($ MYSQL_ETL "update_sql $ {}")
DONE