Posted By

alfirth on 06/28/11


Tagged

Jobs


Versions (?)

Background a certain number of jobs in bash using job control


 / Published in: Bash
 

this works even if you call this script in the background... awesome

  1. #!/bin/bash
  2. for i in {1..10}; do
  3. while [ `jobs | wc -l` -ge 4 ] ; do
  4. sleep 1
  5. done
  6. (echo $i ; sleep 3 ) &
  7. done

Report this snippet  

You need to login to post a comment.