I have a bash script that looks like the following:
##script
#!/bin/bash
rm data*
rm logfile*
for i in {1..30}
do
## append a & if you want to run it parallel;
nohup Rscript --vanilla main.R 10 100 $i &> logfile"$i" &
done
I would like to create another for loop after the first one to continue for another 30. For example
##script
#!/bin/bash
rm data*
rm logfile*
for i in {1..30}
do
## append a & if you want to run it parallel;
nohup Rscript --vanilla main.R 10 100 $i &> logfile"$i" &
for i in {31..60}
do
## append a & if you want to run it parallel;
nohup Rscript --vanilla main.R 10 100 $i &> logfile"$i" &
done
I would like for the first set of jobs to finish before starting the new set. But because of the nohup
it seems that they are all run simultaneously.
I have nohup
because I remotely login to my server and start the jobs there and then close my bash. Is there an alternative solution?
wait
builtin. – Satō Katsura Aug 22 '16 at 15:07