Executing multiple kshs from parent ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing multiple kshs from parent ksh
# 1  
Old 12-28-2009
Executing multiple kshs from parent ksh

Hi,

I have to migrate files from one server to another .For this I am using a mapping file and ksh .The mapping file contains the source and destination directories of the files to be migrated.Each line in the mapping file corresponds to one file that is to be migrated.The ksh upon execution performs the task of connecting to the source server and migrates them to the destnation server.

But the problem is:there are some 20000 files to be migrated and the ksh can process 4000 files in 6 hours.I am thinking of running multiple instances of the ksh from a parent ksh which can run independent of each other,so that parallel processing can be done.
If my parent ksh is parent.ksh and migration ksh is migrate.ksh, how can invoke multiple instances of migrate.ksh from parent.ksh for parallel exec .The migrate.ksh takes the input parameters as from_line and to_line from the mapping file.If in the parent.ksh I write
./migrate.ksh 1 4000
./migrate.ksh 4001 8000
....
Will parallel execution take place?
If not then suggest me a way how this can be done(pls provide code snippet)?

Regards,
Kishore
# 2  
Old 12-28-2009
Hi,

You can use:
Code:
./migrate.ksh 1 4000 &
./migrate.ksh 4001 8000 &
wait

# 3  
Old 12-29-2009
Hi,

Will this code do parallel execution,I mean will
./migrate.ksh 1 4000 and ./migrate.ksh 4001 8000 will run simultaneously,without any dependency?
# 4  
Old 12-29-2009
yes..

as & will make comamnd to run in back ground ... so control will come to next line .. before the earlier one is finished .. and wait at the end will make parent script to wait for all child processes

-----------
wait [n]
Wait for the specified process and return its termination sta-
tus. n may be a process ID or a job specification; if a job
spec is given, all processes in that job's pipeline are waited
for. If n is not given, all currently active child processes
are waited for, and the return status is zero. If n specifies a
non-existent process or job, the return status is 127. Other-
wise, the return status is the exit status of the last process
or job waited for.
-----------
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

One parent, multiple children pipe with fork()

The task I have to do is something along the lines "I receive some input and based on the first character I send it through pipe to one of the children to print". The scheme it is based on is 1->2; 1->3; 1->4; 2 will print all the input that starts with a letter, 3 will print all the input that... (2 Replies)
Discussion started by: Ildiko
2 Replies

2. Shell Programming and Scripting

executing ksh script

I am trying to call a ksh script from another ksh script. in the called script , i am doing sum calculation(used typeset etc) suppose a.ksh is the calling script and b.ksh is the called script . . b.ksh (used this inside a.ksh) this execution gives some error like bad number. but when i... (1 Reply)
Discussion started by: urfrnddpk
1 Replies

3. UNIX for Dummies Questions & Answers

Difference Between executing llike ./myscript.ksh and . ./myscript.ksh

Hi , What is the diffence between executing the script like ./myscript.ksh . ./myscript.ksh I have found 2 difference but could not find the reason 1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
Discussion started by: max_hammer
5 Replies

4. Solaris

Help with executing multiple remote commands after multiple hops

Hi SSHers, I have embedded this below code in my shell script.. /usr/bin/ssh -t $USER@$SERVER1 /usr/bin/ssh $USER2@S$SERVER2 echo uptime:`/opt/OV/bin/snmpget -r 0 -t 60 $nodeName system.3.0 | cut -d: -f3-5` SSH to both these servers are public-key authenticated, so things run... (13 Replies)
Discussion started by: LinuxUser2008
13 Replies

5. UNIX for Advanced & Expert Users

executing a command on parent shell

Hi, I am logging in from my PC terminal to a linux host using ssh. Is it possible to execute a command on the parent PC terminal from the linux host during login. NOte that the parent PC does not have sshd running. Sam (1 Reply)
Discussion started by: sardare
1 Replies

6. UNIX for Dummies Questions & Answers

Specified Ksh but executing in bash

Hi, I am a new bie to unix shell programming. I have specified ksh as the first line in my script but when executed it complains. *********** Script=test******************** #!/usr/bin/ksh echo hello print -p 123 ************************************ ++++++++ Execution... (7 Replies)
Discussion started by: akhilnagpal
7 Replies

7. Shell Programming and Scripting

full path of a file situated either in parent's dir. or parent's parent dir. so on...

hi experts(novice people can stay away as it is no child's game), i am developing a script which works like recycle bin of windows. the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)
Discussion started by: yahoo!
1 Replies

8. Programming

parent not waiting until child complete executing another program through execl()

Hi, I am calling a program that greps and returns 72536 bytes of data on STDOUT, say about 7000 lines of data on STDOUT. I use pipe from the program am calling the above program. Naturally, I execute the above program (through execl() ) throught the child process and try to read the... (4 Replies)
Discussion started by: vvaidyan
4 Replies

9. Shell Programming and Scripting

Killing parent shells from subshells (KSH)

Hi all, I have a shell script which calls other shell scripts, depending on the input. Within a.sh, I have a command which calls b.sh (ie. ksh b.sh) Normally, we use the exit function to terminate a shell. However, if I choose to call exit from b.sh, I will return to the parent shell who... (4 Replies)
Discussion started by: rockysfr
4 Replies

10. UNIX for Dummies Questions & Answers

executing in parent shell.

I have a script that I want to run in my current shell. I know that if I start it with a period ie '. myprogram' that this will cause it to run in my current shell instead of starting a new shell for it. What if I forgot to put the period. Is there some command that I can put in 'myprogram'... (1 Reply)
Discussion started by: Alan Bird
1 Replies
Login or Register to Ask a Question