Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to run many instances of a script with GNU parallel, but the script takes no arguments.

If I just execute 'parallel foo.sh' I get this:

parallel: Warning: Input is read from the terminal. Only experts do this on purpose. Press CTRL-D to exit.
share|improve this question

2 Answers 2

Assuming you want to run ten times, this syntax will work:

parallel -n0 foo.sh ::: {1..10}

parallel needs an input sequence of some length (::: {1..10}) AND you need to ignore the contents of the input sequence(-n0), you only care about its length.

Your original command: parallel foo.sh, contains no input sequence to indicate how much parallelism you want. The cryptic warning is telling you that parallel is going to start listening to the terminal for an input sequence, and that this is probably not what you want.

Here's the tutorial example:

seq 10 | parallel -n0 my_command my_args

How it works:

  • parallel always takes an input sequence from somewhere. It can be an inline space-delimited sequence preceded by ::: OR a newline-delimited sequence from a file or filelike source such as a pipe. In this example the input sequence is from a pipe.
  • seq 10 produces a newline-delimited sequence of digits from one to ten.
  • The -n0 option tells parallel to ignore the values in the input sequence. All we care about is the length of the sequence, not its contents. Even though the digits aren't used, the command will still execute ten times.

Another example:

parallel -n0 echo -n 'x' ::: {1..5}

How it works:

  • Input sequence is inline.
  • {1..5} produces a space delimited sequence of digits from one to five.
  • -n0 ignores sequence values (and we echo the string 'x' each time instead.)
  • Output: xxxxx

Compare to:

parallel echo -n ::: {1..5}

How it works:

  • Input sequence is inline.
  • {1..5} produces a space delimited sequence of digits from one to five.
  • Each value from the input sequence is used as an argument to echo. Order not guaranteed.
  • Output: 43215. Could be any order.
share|improve this answer

Did you read the examples in the manual? Specifically http://www.gnu.org/software/parallel/man.html#example__run_the_same_command_10_times

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.