且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Unix Shell脚本并行运行SQL脚本

更新时间:2021-12-06 22:09:46

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

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