Created
August 16, 2022 03:32
-
-
Save upidea/4e036f3749bff630574743981dd7fa84 to your computer and use it in GitHub Desktop.
bash shell for multiple string into variables and bla..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| export PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
| if [[ $ENGINE_CORE_CLICKHOUSE_USER != '' ]]; then | |
| CLARG="--host ${ENGINE_CORE_CLICKHOUSE_HOST} --port ${ENGINE_CORE_CLICKHOUSE_PORT} --user ${ENGINE_CORE_CLICKHOUSE_USER} --password ${ENGINE_CORE_CLICKHOUSE_PASSWORD}" | |
| elif [[ $ENGINE_CORE_CLICKHOUSE_HOST != '' ]]; then | |
| CLARG="--host ${ENGINE_CORE_CLICKHOUSE_HOST} --port ${ENGINE_CORE_CLICKHOUSE_PORT}" | |
| else | |
| CLARG="--host 127.0.0.1 --port 9000" | |
| fi | |
| read -r -d '' WISHTABLELIST << EOM | |
| 1#yazx_bizsec.tmp_table1 | |
| 2#yazx_bizsec.tmp_table2 on cluster yazx_btdp_cluster | |
| 3#nobody.waht | |
| EOM | |
| echo "$WISHTABLELIST" | while IFS='#' read lc tn; do | |
| #echo $lc :::: $tn | |
| oldtime=`date -d "$lc day ago" +"%Y%m%d"` | |
| docker exec clickhouse touch '/data/clickhouse/flags/force_drop_table' | |
| docker exec clickhouse chmod 666 '/data/clickhouse/flags/force_drop_table' | |
| docker exec clickhouse clickhouse-client $CLARG --query=" | |
| alter table ${tn} drop partition ${oldtime}; | |
| " | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment