Help in running two processes in parellel


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in running two processes in parellel
# 1  
Old 01-13-2010
Data Help in running two processes in parellel

I have a script something like this:

Code:
#!/usr/bin/ksh

CLASSPATH=/apps/opt/db2udb/admin/db2bdt/sqllib/java/db2java.zip:/apps/opt/db2udb/admin/db2bdt/sqllib/java/db2jcc.jar:/apps/opt/db2udb/admin/db2bdt/sqllib/function:$CLASSPATH

export CLASSPATH

LD_LIBRARY_PATH=/apps/opt/db2udb/admin/db2bdt/sqllib/lib32:/apps/opt/db2udb/admin/db2bdt/sqllib/lib64:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH

./extractFile.sh

./loadFiles_new.sh

I have another script in "loadFiles_old.sh"

Code:
./loadFiles_old.sh


The first script is scheduled in a Cron job to be run every morning at 6 AM. In the script, after the "extractFile.sh" process is completed, along with "loadFiles_new.sh", loadFiles_old.sh should also be run. That means, loadFiles_new.sh and loadFiles_old.sh should be kicked off at the same time. And the should be kicked off, only after the extractFile.sh job is completed. This whole script has to run automatically, without any manual intervention.

In a nutshell, the process is like this.... According to the scheduled time, that is 6 AM in the morning, the script will be run.. once the "extractFile.sh" job is completed, "loadFiles_new.sh" will be run.. At the same time when "loadFiles_new.sh" process has begun, "loadFiles_old.sh" should also be kicked off. Please help me in writing a logic on how to coordiante these two processes to be run in parallel?

Can someone help me out in cracking this...
Help is appreciated. Thanks in advance!!
# 2  
Old 01-13-2010
This coordinates three scripts 1.sh, 2.sh, 3.sh the way you describe
Code:
#!/bin/ksh
# mywrapper.shl
/path/to/1.sh
/path/to/2.sh  2>&1 > file2.log &
/path/to/3.sh  2>&1 > file3.log &
wait

This runs 1.sh, then runs 2.sh and 3.sh at the same time and waits until they both finish.
# 3  
Old 01-13-2010
Thanks jim mcnamara for your prompt reply..

Can u please explain it to me how it works and what is # mywrapper.shl ?

Is it because they are being run in the back ground that they run in parellel?
# 4  
Old 01-13-2010
# mywapper.sh1 is a comment.

When the process starts, it executes 1.sh and when that is complete, it spawns a new process for 2.sh (caused by the & at the end of the line), and then immediately spawns 3.sh for the same reason.
The original process then waits for both of the spawned processes to complete.
# 5  
Old 01-14-2010
Heyyy Jim Mcnamara!!!

That worksss!!! I really appreciate it..

U rockkk man!!

Thanks a million!

@ jgt.. I got it.. Thanks a lott!!
# 6  
Old 01-18-2010
I tried running the two processes in parellel, by running them in the background. But, now, the issue is that it is reducing the performance..
If I run them in the foreground, they take only 1 minute to finish. but, if I run them in the bg, they are like taking more than 20 minutes to finish.
Can I improve the performance of the background processes. Is there any way, that I can achieve this.

Any help is highly appreiciated!
# 7  
Old 01-18-2010
use 'nice' to set the priority level.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check Running Processes

I want to check how many processes are running with same names and get their respective counts. ps -ef|grep -Eo 'process1|process2|process3| '|sort -u | awk '{print $2": "$1}' Output would look like : $ ps -ef|grep -Eo 'process1|process2|process3| '|sort | uniq -c | awk '{print $2":... (8 Replies)
Discussion started by: simpltyansh
8 Replies

2. Solaris

Sendmail processes not running

Hi All! I am trying to get sendmail to work but unsuccessfull...when I run ps -ef | grep sendmail root 10578 10561 0 11:01:24 pts/1 0:00 grep sendmail I do not see its processes When I run the following commands: bash-3.00# svcs sendmail svcs: Pattern 'sendmail' doesn't match... (9 Replies)
Discussion started by: fretagi
9 Replies

3. Linux

Running processes

Hi guys is it normal to have 5-10 cron/syslog processes running... in my case i got 10 cron process running. (4 Replies)
Discussion started by: batas
4 Replies

4. Solaris

Running processes on GZ/LZ

Hi guys just a question is it normal to see running process on a non-global zone in the global zone... processes such as cron. (3 Replies)
Discussion started by: batas
3 Replies

5. Shell Programming and Scripting

how to know the running processes.

Hi can anybody help me regarding this.. i want know the output of ps -ef with explanation. how can we know the running processess. this is the output of ps -elf F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 19 T root 0 0 0 0 SY ... (1 Reply)
Discussion started by: rajesh_pola
1 Replies

6. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (5 Replies)
Discussion started by: Ikebana
5 Replies

7. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (2 Replies)
Discussion started by: Ikebana
2 Replies

8. UNIX for Dummies Questions & Answers

identifying running processes

how to identify the processes running by giving the parent process id (1 Reply)
Discussion started by: trichyselva
1 Replies

9. Shell Programming and Scripting

monitoring running processes

I have a script that runs continuously and will deliver a file to multiple servers via scp. On occasions one of the scp's will hang and as a result not complete in sending the remaining files and not loop around again. If I run the scp commands with a & they'll complete, but I want to make sure... (2 Replies)
Discussion started by: nhatch
2 Replies

10. UNIX for Advanced & Expert Users

running processes with no hang up

Can we run a script in nohup which calls another script in nohup. eg Script1.sh #Script1 start nohup script2.sh . . . #end script1.sh Now can I do this nohup script1.sh Also is all scheduled processes (crontab entries) will run as nohup? Would appreciate if any one can... (3 Replies)
Discussion started by: yakyaj
3 Replies
Login or Register to Ask a Question