How to simulate an execution queue with bash?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to simulate an execution queue with bash?
# 1  
Old 07-19-2012
How to simulate an execution queue with bash?

I'm running cygwin bash on windows 7 and I'm have some bat files that perform large builds and take a long time and a lot of memory.

Therefor, I don't want to builds executing simultaneously (too much memory).

How can I implement a queue so I can queue up multiple builds and only execute one at a time?

Here is my attempt, but it does not quite work:

Code:
build.bat one &
a=$!
"wait $a ; build.bat two" &
b=$!
"wait $b ; build.bat three" &
c=$!
etc..

I want $b to contain the pid for the "build.bat two" -- how do I do that?
Now I know I could write a script file to call "build.bat one;build.bat two; build.bat three" but that assumes I know in advance that I want to execute "build.bat two" and not "build.bat four" after "build.bat one".

Thanks
Siegfried
Thanks
Siegfried
# 2  
Old 07-19-2012
Hi,

This will work under linux, i don't have cygwin to check. You can't use wait in the script because you will have error msgs like
Code:
wait: pid 31718 is not a child of this shell

So i loop while the process exist.
Code:
function build
{
    echo "[$2] - Waiting for end of pid $1"
    while [ -e /proc/$1 ]; do
        sleep 0.1;
    done
    shift;
    ./build.sh $@
}

./build.sh one &
build $! two &
build $! three &
build $! four &
build $! five &

# 3  
Old 07-19-2012
give this a shot:

script abc:
Code:
 for i in $@; do build $i; done

then call script with builds in the desired sequence:
Code:
abc one four two &


Last edited by RudiC; 07-19-2012 at 08:26 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simulate keypress in bash

Hello everybody, I am using Windows 10 and cygwin/bash. I need to write a script in bash which simulates opening of a program and then press some keys such as F5, ENTER and ALT+F4. I have written a VBScript which does the job Set WshShell = WScript.CreateObject("WScript.Shell")... (9 Replies)
Discussion started by: supernono06
9 Replies

2. Shell Programming and Scripting

BASH Execution Delay / Speedup

I have a BASH script that runs a continuous loop, reading a line from a file, and then spawning a background process to use it. I've placed "date" commands inside it to see where it's slowing down, and everything inside -- including reading the line from the file -- is fast, but the loop bogs... (34 Replies)
Discussion started by: gmark99
34 Replies

3. Shell Programming and Scripting

How to simulate ''Esc'' keystroke in a bash shel script?

I am using Ubuntu 12.4 I am running the following script: ++++++++ #!/bin/bash while ; do xdotool mousemove 248 539 click 1 & sleep 3 done +++++++++ This moves the mouse on the specified position on the screen and clicks that pauses the script for 3 seconds and repeats the... (2 Replies)
Discussion started by: alfarnume
2 Replies

4. Shell Programming and Scripting

execution of a string being echoed in bash

hi all, I am trying to do a loop on a series of plotting function shown below: colorlist=(blue red green); n=0; for k in $xy; do psbasemap $range -JM$scale -B10g5 -X1 -Y1 -P -K > $outfile pscoast $range -JM$scale -B10g5 -D$res -P -W$lwidth -G$fill -O -K >> $outfile echo... (1 Reply)
Discussion started by: ida1215
1 Replies

5. Shell Programming and Scripting

Execution problems with BASH Shell Script

Hi I need help with my coding , first time I'm working with bash . What i must do is check if there is 3 .txt files if there is not 3 of them i must give an error code , if al three is there i must first arrange them in alphabetical order and then take the last word in al 3 of the .txt files... (1 Reply)
Discussion started by: linux newb
1 Replies

6. Programming

Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX

Writing a Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX I have over the years come across the same issue a couple of times, and it normally is that the read speed on SAN is absolutely atrocious when doing non-sequential I/O to the disks. Problem being of... (7 Replies)
Discussion started by: vrghost
7 Replies

7. Shell Programming and Scripting

Execution Problems with bash script

Hello, can someone please help me to fix this script, I have a 2 files, one file has hostname information and second file has console information of the hosts in each line, I have written a script which actually reads each line in hostname file and should grep in the console file and paste the... (8 Replies)
Discussion started by: bobby320
8 Replies

8. UNIX for Advanced & Expert Users

UNIX Queue command execution

Hello, i was wondering if you could assist me in the following situation: i am trying to queue a group execution commands (same command but different parameters) submited from an openVMS system to a Unix system (HP UX). The commands should run in sequence; the next starts after prev finish... (5 Replies)
Discussion started by: wede23
5 Replies

9. Solaris

Program execution order like FIFO queue

Hi all: I have a problem with a C++ service runing on solaris 10. This service only set a signal on oracle table. When the service detect a cut off on the line (tcp/ip), trigger a cobol program for set the signal OFF. When the line is on again, the service trigger the same cobol program for set... (0 Replies)
Discussion started by: hcastellani
0 Replies

10. Shell Programming and Scripting

simulate session.getMaxInactiveInterval() in bash script

hi everyone, I have a question about the java object oriented function which to simulate in bash script... here is the function "session.getMaxInactiveInterval() / 60 " got any web can read this function? coz i need to simulate to bash script... Hope someone give me a suggestion... (0 Replies)
Discussion started by: ryanW
0 Replies
Login or Register to Ask a Question