Posted: Fri Jul 04, 2008 4:10 am Post subject: multiprocess bash script
Hi there!
Sorry for the title ;-)
I want to let my script do some render jobs...
As I'm using multi-cpu and multi core machines, I thought to split up
the process to be rendered simultaneously...
So lets assume a machine with 4 Cores:
- I would start 4 processes named a, b, c, d
- inside each process I want to do the following
-- start another bash script (which does the rendering) and wait
until its finished to start the same script again, and again, etc.
I want to let my script do some render jobs...
As I'm using multi-cpu and multi core machines, I thought to split up
the process to be rendered simultaneously...
So lets assume a machine with 4 Cores:
- I would start 4 processes named a, b, c, d
- inside each process I want to do the following
-- start another bash script (which does the rendering) and wait
until its finished to start the same script again, and again, etc.
How could I do something like that?
I'm not sure I understand what you want. Note that generally you have no
control over which process gets executed on which cpu. On linux, you can
use taskset (schedutils) to get some control.
If you just want a script that launches a process, waits for it to finish,
launches it again, etc. just do this:
#!/bin/bash
while [ true ]; do
run_other_command
done
But I'm probably missing something.
--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
I want to let my script do some render jobs...
As I'm using multi-cpu and multi core machines, I thought to split up
the process to be rendered simultaneously...
So lets assume a machine with 4 Cores:
- I would start 4 processes named a, b, c, d
- inside each process I want to do the following
-- start another bash script (which does the rendering) and wait
until its finished to start the same script again, and again, etc.
How could I do something like that?
Is this what you want?
while :; do a; done &
while :; do b; done &
while :; do c; done &
while :; do d; done &
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
On Thu, 03 Jul 2008 09:57:03 -0700, horvat.johann wrote:
Quote:
Hi there!
Sorry for the title ;-)
I want to let my script do some render jobs... As I'm using multi-cpu
and multi core machines, I thought to split up the process to be
rendered simultaneously...
So lets assume a machine with 4 Cores: - I would start 4 processes named
a, b, c, d - inside each process I want to do the following
-- start another bash script (which does the rendering) and wait
until its finished to start the same script again, and again, etc.
How could I do something like that?
Thank you
Cheers
Johann
I may be misunderstanding, but it -sounds- like you want something like
this, that'll control your parallelism:
I hope to have a better implementation of the same idea available on the
web before long, but there are licensing constraints - this one's called
"looper".
Anyway, loop is better tested than looper at this point, so that's
probably the way to go for more than one reason.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum