LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Running scripts in parallel (https://www.linuxquestions.org/questions/linux-newbie-8/running-scripts-in-parallel-914325/)

Disha_Pandey 11-18-2011 08:19 PM

Running scripts in parallel
 
I want to run several other shell scripts from this script to run them in parallel (not serially)...save the output of those scripts in different files and they should all show the date (in the saved files, not on screen)..

How can I modify the below script accordingly?

#!/bin/bash
sqlplus -s performance/oracle@WAMS<<eof
set serveroutput on;
SELECT SYSDATE FROM dual;
eof

frankbell 11-18-2011 08:30 PM

I just heard about GNU Parallel on a podcast today. Perhaps you will find it useful:

http://www.gnu.org/s/parallel/

Here's the link to the podcast: http://hackerpublicradio.org/eps.php?id=0860

Disha_Pandey 11-18-2011 08:46 PM

Can you help me modify the above shell script which I have written for parallel execution?

frankbell 11-18-2011 08:55 PM

No, I'm a mere BASH beginner, but the GNU Parallel is GPL, so you could see how he did it. I do recall this is a PERL script, but it might give you some hints.

I would happily help if I could.

tange 11-19-2011 08:57 AM

Quote:

Originally Posted by Disha_Pandey (Post 4527985)
I want to run several other shell scripts from this script to run them in parallel (not serially)...save the output of those scripts in different files and they should all show the date (in the saved files, not on screen)..

How can I modify the below script accordingly?

#!/bin/bash
sqlplus -s performance/oracle@WAMS<<eof
set serveroutput on;
SELECT SYSDATE FROM dual;
eof

It is unclear what you want. The script you have cannot be parallelized as there is only one sql job to be run. But if you have loads of these jobs they can be run in parallel using parallel and sql (both part of GNU Parallel):

Code:

$ cat sqljobs
SELECT SYSDATE FROM dual;
SELECT 1+2 FROM dual;
SELECT * FROM foo;
... (other SQL statements you want to run in parallel - one per line)

Code:

$ cat sqljobs | parallel -j10 sql oracle://scott:tiger@ora.example.com/xe ">"{#}
It will save the output from each job into a file called the job number of sqljobs.

Adjust -j10 to run more/less jobs in parallel (-j0 = as many as possible - which may overload your Oracle server).

If that is not what you want you need to give 3 examples of the jobs you want run in parallel and the corresponding file names they should be saved as.


All times are GMT -5. The time now is 04:53 AM.