Running shell script in parallel

后端 未结 8 2029
无人及你
无人及你 2020-11-30 19:35

I have a shell script which

  1. shuffles a large text file (6 million rows and 6 columns)
  2. sorts the file based the first column
  3. outputs 1000 fi
8条回答
  •  伪装坚强ぢ
    2020-11-30 20:29

    Check out bash subshells, these can be used to run parts of a script in parallel.

    I haven't tested this, but this could be a start:

    #!/bin/bash
    for i in $(seq 1 1000)
    do
       ( Generating random numbers here , sorting  and outputting to file$i.txt ) &
       if (( $i % 10 == 0 )); then wait; fi # Limit to 10 concurrent subshells.
    done
    wait
    

提交回复
热议问题