Created
August 4, 2016 03:27
-
-
Save theidexisted/ea0eff594176da87785c24208c7b79eb to your computer and use it in GitHub Desktop.
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 | |
work_dir="/home/zampread/banker_cost" | |
date=`date +"%Y_%m_%d"` | |
data_minute=`date +"%Y_%m_%d_%H_%M"` | |
table_name="banker_record_"$date | |
output_file="banker_cost_"$data_minute | |
current_file="banker_cost_current.txt" | |
function query_mysql { | |
sql_statement="mysql --host=172.22.0.0 --port=3306 --user=user_b --password=j --database=banker -e 'select campaign_id, sum(cost) from "$table_name" where update_time>=(curdate()+interval hour(curtime()) hour) group by campaign_id;' > "$output_file | |
eval $sql_statement | |
echo $output_file > $current_file | |
} | |
function uploading { | |
#echo "uploading to ftp server" | |
ftp_srv="172.22.41.102" | |
ftp_user="zamplusftp" | |
ftp_pwd="zamp1234" | |
ftp_path="/home/zamplusftp/test_dir" | |
local_path="~" | |
ftp -n $ftp_srv &> /dev/null <<-EOT | |
binary | |
user $ftp_user $ftp_pwd | |
prompt | |
cd test_dir | |
lcd $work_dir | |
put $output_file | |
put $current_file | |
bye | |
EOT | |
} | |
mkdir -p $work_dir | |
cd $work_dir | |
query_mysql | |
uploading |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment