Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Spawn Process, Is it possible to have a korn shell script spawn multiple processes
demanaz
post Nov 28 2008, 03:41 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 6
Joined: 28-November 08
Member No.: 13,769



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
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
docmur
post Dec 2 2008, 06:59 AM
Post #2


I Eat C Code for Breakfast
****

Group: Members
Posts: 276
Joined: 9-November 04
From: Canada Ontario
Member No.: 4,136



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


--------------------
Gentoo ROCKS!!!!! Go and emerge the world
Go to the top of the page
 
+Quote Post
demanaz
post Dec 4 2008, 10:15 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 6
Joined: 28-November 08
Member No.: 13,769



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?
Go to the top of the page
 
+Quote Post

Posts in this topic
- demanaz   Spawn Process   Nov 28 2008, 03:41 PM
- - docmur   Sure you can just take a look at forking the proce...   Dec 2 2008, 06:59 AM
- - demanaz   QUOTE (docmur @ Dec 2 2008, 05:59 AM) Sur...   Dec 4 2008, 10:15 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 20th November 2017 - 07:56 PM