Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

execute command only after gnu parallel runs all jobs

I have the bash file -

cat input.txt | parallel -j4 'python {}'

cp -r outputs /home/usr/my_outputs

I want to copy outputs to my_outputs only after all jobs finish executing. Presently, it looks like parallel returns immediately (after starting the jobs) and then cp -r is executed immediately, but I want to wait for the jobs to finish executing before I copy. How do I do this? Thanks!

EDIT: input.txt is like -

run1.py -n 5 
run2.py -n 5 
run3.py -n 5 
run4.py -n 5 
like image 819
rohit_r Avatar asked Aug 12 '26 14:08

rohit_r


1 Answers

Try:

parallel --colsep ' '

otherwise you are effectively trying to run:

python 'run1.py -n 5'

which means the Python interpreter is looking for a script called run1.py -n 5

like image 108
Mark Setchell Avatar answered Aug 21 '26 05:08

Mark Setchell