I've been trying to run a while-loop in parallel for a work that takes days.
I've seen other answers where parallel was implemented within a while-loop, but for that case it does work in blocks, where the next job only works after all previous jobs finished.
This is the code, which reproduced the two columns of the CSV file:
while IFS="," read fq tab
do
echo $fq
echo $tab
done < /home/samples.csv
where the csv file contain two columns with no header (column 1 and 2), where the variables are stored. For example:
a1,b1
a2,b2
a3,b3
a4,b4
I've been trying to run this in parallel so when a job is finished the other starts immediately because of the long run times.
This is the code:
while IFS="," read fq tab
do
parallel -j 1 --verbose --delay 2 "echo $fq; echo $tab"
done < /home/samples.csv
But this produces
a1 b1 a1,b1
a1 b1 a2,b2
a1 b1 a3,b3
a1 b1 a4,b4
And not
a1 b1
a2 b2
a3 b3
a4 b4
a1 b1for processinga2 b2then you can't parallelize the codeparallel -j 3 -a /home/sample.csv --colsep ',' echo {1} {2}. Knowing if this will suit your final goal is an other story.IFS=","but there are no commas in the input file; consider reviewing How to create a minimal, reproducible example? and then come back and update your question accordingly, making sure your expected output matches the sample input you provide