正在等待mysql查询在bash脚本中终止

正在等待mysql查询在bash脚本中终止,mysql,linux,bash,Mysql,Linux,Bash,我试图编写一个bash脚本,在文本文件中迭代一系列mysql查询。我尝试使用以下脚本 #!/bin/bash # Process files for x in {1...8} do nohup mysql < coauthorquery$x.txt & mv nohup.out coauthor$x.csv done #/bin/bash #处理文件 对于{1…8}中的x 做 nohup mysql

我试图编写一个bash脚本,在文本文件中迭代一系列mysql查询。我尝试使用以下脚本

#!/bin/bash
# Process files

for x in {1...8}
do
    nohup mysql < coauthorquery$x.txt &
    mv nohup.out coauthor$x.csv
done
#/bin/bash
#处理文件
对于{1…8}中的x
做
nohup mysql
但是它失败了,因为nohup.out直到文本文件中的查询完成后才出现。为暂停选择固定的持续时间是不可行的,因为查询的长度是可变的。如何暂停脚本直到查询完成?

使用命令

nohup-mysql
或者,不要在后台运行该命令

nohup mysql < coauthorquery$x.txt
mv nohup.out coauthor$x.csv
nohup-mysql
那么,不要把它放在后台。消除
nohup mysql < coauthorquery$x.txt
mv nohup.out coauthor$x.csv