The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Repeated execution of Autosys Jobs Data469 Shell Programming and Scripting 2 02-28-2008 12:24 PM
Running 2 Drives simultaneously? Infidel Filesystems, Disks and Memory 4 01-24-2008 04:55 AM
background jobs exit status and limit the number of jobs to run GrepMe Shell Programming and Scripting 1 06-11-2007 03:56 PM
How to parse 2 files simultaneously Awanka Shell Programming and Scripting 8 04-12-2007 05:00 PM
cp & mkdir simultaneously enuenu UNIX for Dummies Questions & Answers 5 03-13-2007 01:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2006
Registered User
 

Join Date: Dec 2005
Posts: 20
Stumble this Post!
Execution of two jobs simultaneously

Hi All,
I have a script and a diff program,(lets say a java program) which needs to be excuted simulaneously. What I am currently doing is excuting one in foregound and the other in the back ground. But as running the job in the background does not always fruitful, especially when the jobs are really taking few hours to get completed. Why I need simultaneous execution is both the jobs are taking hours to execute, so I just can not wait for the first one to get executed and then the next. Even my task does not stop there. I have to process some thing more after the execution of these two jobs.
Am sure that I will get several alternatives to my approach. Looking for all of them..

Thanks in advance,

Regards,
...rin...
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-08-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,804
Stumble this Post!
You can "multi-process" jobs, we do it all the time. For example, take the apply payments to accounts job. Running the account payment job on all accounts takes four hours.

Running the eight simultaneous versions of the same job (passing a parameter) and having each job work on a subset of accounts has a total run-time of about 40 minutes. like this:

Code:
#!/bin/ksh
acctjob 1-10000 &
acctjob 10001-20000 &
......
wait
Reply With Quote
  #3 (permalink)  
Old 03-08-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,546
Stumble this Post!
Quote:
But as running the job in the background does not always fruitful, especially when the jobs are really taking few hours to get completed.
The above Pt cannot be accepted,
there is no relation or relavance in running a process bg or fg and the time it takes to complete.

only thing, background process when attempting to block on a read call through the command interpretor would be signalled to stop temporarily by the kernel.
Reply With Quote
  #4 (permalink)  
Old 03-08-2006
Registered User
 

Join Date: Dec 2005
Posts: 20
Stumble this Post!
Quote:
Originally Posted by matrixmadhan
The above Pt cannot be accepted,
there is no relation or relavance in running a process bg or fg and the time it takes to complete.

only thing, background process when attempting to block on a read call through the command interpretor would be signalled to stop temporarily by the kernel.
Thanks Jim and Matrix for your prompt response.
Jim,
I am currently working the same way what you have mentioned. But I am not very much sure about your point of time getting splitted among different processes. In fact this is a load on the processor and the time for processing for uni processor machines will get affected. Hence it will take more time to execute each individual.
Let me put the way, I am doing.

#! /usr/bin/ksh
ksh abc.ksh & ## knowing that this job will take less time (2 hrs)
java xyz ## this is a quite longer job (4hrs)
wait ## assuming a case when the script will takemore
## time than the java
.
..
...
#some other processing which needs both the jobs finised
...
..
.

Earlier I used to run the jobs sequencially which was talking 6hrs+. But after doing the above said way, I did not feel any noticable improvements. That is the reason why I came up putting in from of right people.
What I need is the above jobs should get executed with a maximum time of time taken by java program, i.e 4 hrs in this case.
Any suggestion is welcome.
Regards,
...rin...
Reply With Quote
  #5 (permalink)  
Old 03-08-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,426
Stumble this Post!
Quote:
Originally Posted by matrixmadhan
The above Pt cannot be accepted,
there is no relation or relavance in running a process bg or fg and the time it takes to complete.
This may not be true. An interactive ksh will typically the option bgnice set and so it will worsen the priority of commands it runs in the background.

Speaking of nice values, rinku11, maybe this will help a little bit....
#! /usr/bin/ksh
nice 4 ksh abc.ksh & ## knowing that this job will take less time (2 hrs)
java xyz ## this is a quite longer job (4hrs)
wait ## assuming a case when the script will takemore
## time than the java

But ultimately, maybe you need a few more cpu's.
Reply With Quote
  #6 (permalink)  
Old 03-09-2006
Registered User
 

Join Date: Dec 2005
Posts: 20
Stumble this Post!
Quote:
Originally Posted by Perderabo
Speaking of nice values, rinku11, maybe this will help a little bit....
#! /usr/bin/ksh
nice 4 ksh abc.ksh & ## knowing that this job will take less time (2 hrs)
ultimately, maybe you need a few more cpu's.
Let me correct this. It should be
nice -n 4 ksh abc.ksh &
But let me repeat, this job is taking comparatively less time. Hence I need not put priority to this job. Rather I can do the same for the other job.

Till now we are talking about one solution only. What I was expecting was multiple solutions to my problem, from the Gurus' like you people. Come up with any probable solution and we can always discuss on that.
Hats up to Unix Gurus'...
Reply With Quote
  #7 (permalink)  
Old 03-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 1
Stumble this Post!
hi
i need to know that how can i know user id and my group id in which i m currently working
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0