title: Wait for set of qsub jobs to complete
body: <p>I have a batch script which starts off a couple of qsub jobs, and I want to trap when they are all completed.</p>
  
  <p>I don't want to use the -sync option, because I want them to be running simultaneously. Each job has a different set of command line parameters.</p>
  
  <p>I want my script to wait till when all the jobs have been completed, and do something after that. I don't want to use the sleep function e.g. to check if certain files have been generated after each 30 s, because this is a drain on resources.</p>
  
  <p>I believe Torque may have some options, but I am running SGE.</p>
  
  <p>Any ideas on how I could implement this please?</p>
  
  <p>Thanks
  P.s.
  I did find another thread
  <a href="https://stackoverflow.com/questions/3886168/how-to-automatically-run-a-bash-script-when-my-qsub-jobs-are-finished-on-a-serve">Link</a></p>
  
  <p>which had a reponse</p>
  
  <p><em>You can use wait to stop execution until all your jobs are done. You can even collect all the exit statuses and other running statistics (time it took, count of jobs done at the time, whatever) if you cycle around waiting for specific ids.</em></p>
  
  <p>but I am not sure how to use it without polling on some value. Can bash trap be used, but how would I with qsub?</p>