Execution of two jobs simultaneously


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution of two jobs simultaneously
# 1  
Old 03-08-2006
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...
# 2  
Old 03-08-2006
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

# 3  
Old 03-08-2006
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.
# 4  
Old 03-08-2006
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...
# 5  
Old 03-08-2006
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.
# 6  
Old 03-09-2006
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'...
# 7  
Old 03-14-2006
hi
i need to know that how can i know user id and my group id in which i m currently working
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to run multiple jobs and it's dependent jobs

I have multiple jobs and each job dependent on other job. Each Job generates a log and If job completed successfully log file end's with JOB ENDED SUCCESSFULLY message and if it failed then it will end with JOB ENDED with FAILURE. I need an help how to start. Attaching the JOB dependency... (3 Replies)
Discussion started by: santoshkumarkal
3 Replies

2. Shell Programming and Scripting

waiting on jobs in bash, allowing limited parallel jobs at one time, and then for all to finish

Hello, I am running GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu). I have a specific question pertaining to waiting on jobs run in sub-shells, based on the max number of parallel processes I want to allow, and then wait... (1 Reply)
Discussion started by: srao
1 Replies

3. Solaris

Cron jobs and at jobs

There are two jobs in Solaris , Cron and at jobs.. I know how to disable or enable cron jobs. How can I enable at jobs and disable it. Kindly help. Rj (2 Replies)
Discussion started by: jegaraman
2 Replies

4. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

5. Shell Programming and Scripting

Run a command in bg simultaneously with

Hi, I want to run the command below in the background: tail -f file.txt | grep "pattern" The file file.txt will start getting its contents written after this command has started getting run. So the flow will be like this tail -f file.txt | grep "pattern" #The line below will write data... (0 Replies)
Discussion started by: King Nothing
0 Replies

6. Shell Programming and Scripting

Conditional execution and parallel jobs

how can i process jobs parallel with conditions below. Script1.ksh Script2.ksh Script3.ksh Script4.ksh Script5.ksh Script6.ksh Script7.ksh Script8.ksh Script9.ksh Script10.ksh After successful completion of Script1.ksh I need to run Script7.ksh. After successful... (4 Replies)
Discussion started by: ford2020
4 Replies

7. Shell Programming and Scripting

Repeated execution of Autosys Jobs

post deleted ... (2 Replies)
Discussion started by: Data469
2 Replies

8. Shell Programming and Scripting

background jobs exit status and limit the number of jobs to run

i need to execute 5 jobs at a time in background and need to get the exit status of all the jobs i wrote small script below , i'm not sure this is right way to do it.any ideas please help. $cat run_job.ksh #!/usr/bin/ksh #################################### typeset -u SCHEMA_NAME=$1 ... (1 Reply)
Discussion started by: GrepMe
1 Replies

9. UNIX for Dummies Questions & Answers

cp & mkdir simultaneously

Can I create a new directory and copy files to it in a single command (not by linking 2 commands with a semi colon)? If so how? The only way I can see to do it is to first create the new directory using mkdir THEN copy files to it using the cp command. (5 Replies)
Discussion started by: enuenu
5 Replies

10. Solaris

Running 2 apaches simultaneously

Hello, I want to run 2 apaches simultaneusly in a system, one operating with port 80 and the other one with 85, i already have the configuration files ready and i tryed something i saw in a manual, like this: first i start apache as normal: /usr/local/etc/httpd/bin/apachectl start the i... (2 Replies)
Discussion started by: sx3v1l_1n51de
2 Replies
Login or Register to Ask a Question