LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-27-2010, 05:20 PM   #1
kmkocot
Member
 
Registered: Dec 2007
Location: Queensland, Australia
Posts: 122

Rep: Reputation: 15
Simultaneously execute 8 instances of a program until all input files are processed?


Hi all,

I have a machine with 8 cores. I have a directory of input files that I need to process using a non-parallelized program. I would like to write a script that works its way through a list of commands executing 8 commans (i.e., instances of this program; each with specific flags having to do with the current input file) until the list of commands has been exhausted. Is there an easy way to do this?

Code:
hamstrsearch_local-hmmer3.pl -protein -refspec=lotgi_2713 -hmmset=lophotrochozoa_hmmer3 -sequence_file=Aplysia_californica.fas -taxon=ACAL
Thanks!
Kevin
 
Old 09-27-2010, 08:14 PM   #2
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 90
I removed my reply because it was not useful for the OP.

Last edited by SharpyWarpy; 09-28-2010 at 07:22 AM. Reason: Inappropriate
 
Old 09-27-2010, 11:02 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,050

Rep: Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915
Hopefully that little rant makes SharpyWarpy feel better ...

Now to the matter at hand.
And yes the requirements are a little vague. But assuming you mean 8 instances per input file, something as basic as this should suffice
Code:
#! /bin/sh
for file in /some/directory/*
  do
    program -f flags1 ${file} &
    program -f flags2 ${file} &
    program -f flags3 ${file} &
    program -f flags4 ${file} &
    program -f flags5 ${file} &
    program -f flags6 ${file} &
    program -f flags7 ${file} &
    program -f flags8 ${file} &
  done
That will (immediately) spawn 8 per infile, so you could wind up with quite a few. Niceties might be to add a sleep after number 8, or count the instances and limit the number of concurrent instances, ...
 
1 members found this post helpful.
Old 09-30-2010, 05:51 PM   #4
kmkocot
Member
 
Registered: Dec 2007
Location: Queensland, Australia
Posts: 122

Original Poster
Rep: Reputation: 15
Thanks! This is extremely helpful!

(and in retrospect I realize that my question wasn't entirely clear but I think you got my meaning)

Kevin

Last edited by kmkocot; 09-30-2010 at 05:53 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Awk: Input from one line, execute program; input from next line, execute program C.L. Programming 9 09-27-2010 01:06 AM
Have multiple files open in different instances of a program vwtech Linux - Newbie 1 12-28-2007 02:19 AM
Open multiple files in different instances of a program vwtech Linux - Newbie 2 12-24-2007 12:29 PM
Start two instances of a program simultaneously using bash Daws Linux - General 5 05-26-2007 01:54 PM


All times are GMT -5. The time now is 09:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration