How to run script concurrently


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to run script concurrently
# 1  
Old 06-02-2011
How to run script concurrently

Hi all,

I have one script. Its job is to get 1 file from dirA and 1 file from dirB as parameters for another python script.

However, there are a lot of files in both dir A and B, so running this scripts really takes a lot of time. So I wonder if there are any ways that I can do this faster, by running it concurrently, maybe?

Much thanks in advance.
H.P
# 2  
Old 06-02-2011
currently how you are taking the file from dirA and dirB

please post the script
# 3  
Old 06-02-2011
Hi,

It's something like this:

Code:
for F in `cd A; echo a*`
do
    for G in `cd B; echo b*`
    do
        ./scripts/XYZ.py A/$F B/$G | gzip > out.$F.$G.gz
    done
done

The problem is that there are a lot files in A and B, so this takes very long time.
# 4  
Old 06-02-2011
you can do it by running the python script in backgroud
Background Process - Foreground Process
or use nohup (en.wikipedia.org/wiki/Nohup)
# 5  
Old 06-02-2011
Hi,

Thanks for your reply Smilie

I have tried nohup, it works nicely, yet still needs a lot of time. And I cannot continue doing things without the result from this step.

I have been waiting from yesterday morning until now. Just now with some simple calculations, I guess I need at least 77 days to get its done T___T. That is why I am here.
# 6  
Old 06-02-2011
Hi,

nohup is there to make sure that there is no chance any of these will be stopped i.e. killing the shell. You don't want it running in the background you want it running quickly in parallel. But not a bad suggestion at all.


Your code , if that is what you use needs a lot of optimization.


For example if you have 1000 a* files your

Code:
for G in `cd B; echo b*`

seems to run forever.... what is the problem there? the 'cd' command....

change it to something like


Code:
VAR1=`cd A; echo a*`
for F in $VAR1

for a start, that should make it run a lot faster.


Also , depending on the optimization we get from the first debug (meainng you change your code, run it again and then we see how much time these changes have earned you) we use other methods.... like

Code:
./scripts/XYZ.py A/$F B/$G | gzip > out.$F.$G.gz &

# 7  
Old 06-02-2011
Hi,

Thank you very much Smilie I will try it out tomorrow Smilie

And I also found something interesting: the task spooler command TS
Code:
http://vicerveza.homeunix.net/~viric/soft/ts/man_ts.html

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

3. AIX

Restore and upgrade concurrently

I have serveral servers that are at AIX 6.1 tl4 sp1 and want to move them to new hardware and upgrade them at the same time. Using NIM and sysback images I want to backup the current server with sysback and restore it and upgrade it to AIX 6.1 tl4 sp6 to the new hardware using my NIM server. My... (4 Replies)
Discussion started by: daveisme
4 Replies

4. Shell Programming and Scripting

Running function or command concurrently in a bash script

I currently run a script over a vpnc tunnel to back-up my data to a remote server. However for a number of reasons the tunnel often collapses. If I manually restore the tunnel then the whole thing can continue, but I want to add into my script a section whereby while the transfer is taking place,... (8 Replies)
Discussion started by: dj_bridges
8 Replies

5. Shell Programming and Scripting

Trimming files concurrently

I have a file which is written by an ongoing process (actually it is a logfile). I want to trim this logfile with a script and save the trimmed portion to another file or display it to <stdout> (it gets picked up there by another process). Fortunately my logfile has a known format (XML) and i... (3 Replies)
Discussion started by: bakunin
3 Replies

6. Shell Programming and Scripting

Running same script multiple times concurrently...

Hi, I was hoping someone would be able to help me out. I've got a Python script that I need to run 60 times concurrently (with the number added as an argument each time) via nightly cron. I figured that this would work: 30 1 * * * for i in $(seq 0 59); do $i \&; done However, it seems to... (4 Replies)
Discussion started by: ckhowe
4 Replies

7. Programming

how to run socket programme and file management concurrently

hi i have a server socket programme which is running in HP/UX system and then need to add a function about refreshing memory every miniute because the socket programme is blocked , i have no idea about this what should i do thanks (10 Replies)
Discussion started by: benbenpig
10 Replies

8. Programming

Run 4-processes concurrently

How can i run a back ground process.... I.e for example by using fork() i need to run seperate 4 background processes.. How can send a process to background ??? (9 Replies)
Discussion started by: ugp
9 Replies

9. Shell Programming and Scripting

Executing multiple Oracle procedures concurrently

I am using KSH with an OS of AIX Version 5.3. From my shell script, that will be scheduled thorugh a CRON, I need to execute 2 Oracle stored procedures concurrently. If we execute them one at a time, the total execution time takes 4 hours or more. Since they are not dependent on each other and... (6 Replies)
Discussion started by: multidogzoomom
6 Replies
Login or Register to Ask a Question