模版
#!/bin/bash
#扫描环境文件,根据需要设置
source /root/gsql_env_v2.sh
echo "################################################################"
temp_fifo_file=/tmp/$$.fifo
mkfifo $temp_fifo_file
exec 6<>$temp_fifo_file
rm $temp_fifo_file
#设置并发进程数
temp_thread=20
for ((i=0;i
do
#设置并发占位
echo
done >&6
while read line
do
read -u6
{
echo $line
#gsql -h 25.34.0.130 -p 8000 -U sjzt_admin -d tjdl_sjzt_db1 -W ^B1myD*c3! -c "select * from public.table_map_system_sc;
#\q"
#添加自己执行的业务逻辑即可
echo >&6
}&
done
# 等待所有的执行完
wait
exec 6>&-
案例
CREATE TABLE public.standard_gsql_status (
standard_table character varying(500),
standard_date timestamp(0) without time zone,
standard_status character varying(100),
begin_time timestamp(0) without time zone,
end_time timestamp(0) without time zone
)
#!/bin/bash
source /root/gsql_env_v2.sh
echo "################################################################"
log_date=`date +%Y-%m-%d`
temp_fifo_file=/tmp/$$.fifo
mkfifo $temp_fifo_file
exec 6<>$temp_fifo_file
rm $temp_fifo_file
#设置进程数
temp_thread=20
for ((i=0;i
do
echo
done >&6
while read line
do
read -u6
{
table_name=`echo $line|awk -F ',' '{print $4}'`
gsql -h 25.34.0.130 -p 8000 -U sjzt_admin -d tjdl_sjzt_db1 -W ^B1myD*c3! -c "
delete from public.standard_gsql_status where standard_date = '$log_date' and standard_table = $table_name;
insert into public.standard_gsql_status(standard_table,standard_date,standard_status,begin_time) values ($table_name,'$log_date','running',sysdate); \q"
#-v "ON_ERROR_STOP=1"
gsql -h 25.34.0.130 -p 8000 -U sjzt_admin -d tjdl_sjzt_db1 -W ^B1myD*c3! -v "ON_ERROR_STOP=1" -c "
declare
var_cnt text;
begin
select $line into var_cnt;
end "
if [ $? = 0 ];then
gsql -h 25.34.0.130 -p 8000 -U sjzt_admin -d tjdl_sjzt_db1 -W ^B1myD*c3! -c "
update public.standard_gsql_status set standard_status = 'success',end_time=sysdate where standard_date = '$log_date' and standard_table = $table_name; \q"
else
gsql -h 25.34.0.130 -p 8000 -U sjzt_admin -d tjdl_sjzt_db1 -W ^B1myD*c3! -c "
update public.standard_gsql_status set standard_status = 'fail',end_time=sysdate where standard_date = '$log_date' and standard_table = $table_name; \q"
fi
echo >&6
}&
done
# 等待所有的执行完
wait
exec 6>&-