Correct order of parallel execution of shell `time` command

169 views Asked by At

I need to execute the command below (as part of a script) but I don't know in what order to put things so that it executes correctly. What I am trying to do is to give file.smt2 as input to optimathsat, execute it, get the execution time. But I want this to be done several times in parallel using all CPU cores.

parallel -j+0 time Desktop/optimathsat-1.5.1-macos-64-bit/bin/optimathsat < file.smt2 &>results.csv 

I added #!/bin/bash -x at the beginning of my file to look at what is happening and this was the output:

+ parallel -j+0 time file.smt2
parallel: Warning: Input is read from the terminal. You are either an expert
parallel: Warning: (in which case: YOU ARE AWESOME!) or maybe you forgot.
parallel: Warning: ::: or :::: or -a or to pipe data into parallel.

...from the 1st line, I can tell the order is wrong. From line 2,3 and 4 the syntax is lacking. How can I fix this?

1

There are 1 answers

0
Ole Tange On

So I take it you do not care about the results, but only the timing:

seq $(parallel --number-of-threads) |
  parallel -j+0 -N0 --joblog my.log 'Desktop/optimathsat-1.5.1-macos-64-bit/bin/optimathsat < file.smt2'
cat my.log

-N0 inserts 0 arguments.

Consider reading GNU Parallel 2018 (printed, online) - at least chapter 1+2. Your command line will thank you for it.