![]() |
| | #1 |
| Registered User Join Date: Jan 2009
Posts: 159
| How to parallel several jobs in bash I wonder how to in a bash script(or other languages if more convenient and/or fast) manage independent jobs(executables with command line arguments) and make them run in parallel? Is there a way to create several sub-process without waiting them to finish? Which one is faster: multi-threading or multi-process? Thanks and regards! |
| lehe is offline | |
| | #2 |
| mastering the obvious Join Date: Jul 2008 Location: SE Queens
Posts: 5,068
| You can put a command into the background: ./myscript.sh & This forks() and returns the command prompt right away *before* the script finishes, so you can start another one right away. You can put a string of these in a file: Code: #!/bin/bash /home/user/bin/myscript1.sh & /home/user/bin/myscript2.sh & /home/user/bin/myscript3.sh &
__________________ “The essential element in the black art of obscurantism is not that it wants to darken individual understanding, but that it wants to blacken our picture of the world, and darken our idea of existence.” [Friedrich Wilhelm Nietzsche, 1878] |
| MK27 is offline | |
| | #3 |
| Registered User Join Date: Jan 2009
Posts: 159
| Thanks! is running background slower than foreground? |
| lehe is offline | |
| | #4 |
| mastering the obvious Join Date: Jul 2008 Location: SE Queens
Posts: 5,068
| AFAIK there is no reason for it to be, depending on the console interaction and how the script is written it could be faster, but it should be the same generally.
__________________ “The essential element in the black art of obscurantism is not that it wants to darken individual understanding, but that it wants to blacken our picture of the world, and darken our idea of existence.” [Friedrich Wilhelm Nietzsche, 1878] |
| MK27 is offline | |
| | #5 |
| Jaxom's & Imriel's Dad Join Date: Aug 2006 Location: Alabama
Posts: 863
| The only issue would be a race condition for resources. If you have many processes fighting for the same disc, for example, then your overall performance will decline. Otherwise, each process will get a time slice for each task. |
| Kennedy is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parallel Port to USB controller and outb() | coletek | Linux Programming | 1 | 06-05-2009 06:57 AM |
| argument with space passed to bash script and further to executable | lehe | Linux Programming | 3 | 04-10-2009 12:57 AM |
| Open C/C++ Jobs for Top Developers | Susan N | Projects and Job Recruitment | 7 | 06-04-2008 08:56 PM |
| Serial to Parallel | ssharish2005 | Tech Board | 11 | 09-10-2007 01:11 PM |
| Segmentation Fault - Trying to access parallel port | tvsinesperanto | C Programming | 3 | 05-24-2006 03:28 AM |