Unix Shell脚本并行运行SQL脚本 [英] Unix shell script run SQL scripts in parallel

查看:301
本文介绍了Unix Shell脚本并行运行SQL脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在完成tst1.sql之后,如何设置此KornShell(ksh)脚本在 parallel 中运行SQL脚本2,3,然后在完成2,3之后运行tst4.sql?这可能吗?

How do I setup this KornShell (ksh) script to run SQL scripts 2,3 in parallel after tst1.sql is done then run tst4.sql after 2,3 are complete? Is this possible?

#/usr/bin/ksh
#SET ENVIRONMENT ORACLE

sqlplus user1/pw @/home/scripts/tst1.sql
sqlplus user1/pw @/home/scripts/tst2.sql
sqlplus user1/pw @/home/scripts/tst3.sql
sqlplus user1/pw @/home/scripts/tst4.sql
exit 0

推荐答案

第一个命令应同步运行...

The first command should run synchronously...

如果您将最后两个命令作为后台进程启动(在命令末尾添加& amp;),则它们将并行运行.

If you start the two last commands as background processes (add & at the end of the command), they will run in parallel.

您是否要让脚本在离开之前等待最后两个进程完成?

Do you want the script to wait for the two last processes to be complete before leaving?

类似的事情应该起作用:

Something like this should work:

  sqlplus user1/pw @/home/scripts/tst1.sql
  sqlplus user1/pw @/home/scripts/tst2.sql &
  pid2=$!
  sqlplus user1/pw @/home/scripts/tst3.sql &
  pid3=$!
  # pseudo-code:
  # while (`ps -p"$pid2,$pid3" | wc -l` != "1");
  sqlplus user1/pw @/home/scripts/tst4.sql

这篇关于Unix Shell脚本并行运行SQL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆