Help - Search - Members - Calendar
Full Version: Spawn Process
Linuxhelp > Support > Programming in Linux
demanaz
Hi all:

I'm writing a korn shell script that runs on one box and connects to multiple (100+) boxes:

################ SCRIPT: ########################
#!/bin/ksh

for srv in `cat server_list|grep -v '#'`
do
echo "starting $srv"
ssh $srv "./extract_script"
scp $srv:/scripts/extract_script_output extract_script_output_$srv
echo "finished $srv"
done

################ SCRIPT: ########################

(the actual script does a lot more, but this is the basic idea)

Is it possible in ksh to spawn the for loop statements into other processes so i can be running the commands on all the servers at the same time w/o having to wait for each server to finish?

I could schedule the extract_script to run on each server individually, but then i have to maintain 100+ versions/schedules. This would be the easiest way for maintaince...

thx in advance
docmur
Sure you can just take a look at forking the process using fork() and that pass the execution of the process using execvp() then korn will spawn a new instance of a shell for each process so you don't have to wait for one to finish first.

Thanks

Docmur
demanaz
QUOTE (docmur @ Dec 2 2008, 05:59 AM) *
Sure you can just take a look at forking the process using fork() and that pass the execution of the process using execvp() then korn will spawn a new instance of a shell for each process so you don't have to wait for one to finish first.

Thanks

Docmur



I had researched forking and it sounded kind of dangerous in that processes could get spawned out of control. i wasnt sure if there was a safer way to do this. do you have any guides on forking you recommend?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.