Running Multiple Times ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running Multiple Times ?
# 1  
Old 10-12-2011
Running Multiple Times ?

hey mates,

I was wondering if someone could assist me with this one, I have couple scripts that I would like to invoke from .sh ( One after another )

Script1
Script2
Script3

Is it possible to run script 2 after script one finished running ? And again start script 3 after script 2 finished running ...

Does it make any sense

Help would be highly appreciated.
# 2  
Old 10-12-2011
Perhaps I don't understand your questions, but these three lines in a row would seem to do what you want:
Code:
./script1.sh
./script2.sh
./script3.sh

Or all on one line:
Code:
./script1.sh ; ./script2.sh ; ./script3.sh

If that's not what you want, then what do you want?
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 10-12-2011
Let me try to rephrase this,

I have one script lets call it script1.sh

And this script includes multiple commands inside

I would like to run those commands 1 at the time after one command is done it work I would like to execute 2nd one and then 3rd one etc....

I don't want to run them all at the same time because that would be overkill for the system.

thank you again
# 4  
Old 10-12-2011
That's exactly what you said before, and exactly what my examples do.

Try
Code:
sleep 1
echo a
sleep 1
echo b
sleep 1
echo c

it runs them in order, waiting for the previous ones to end.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 10-12-2011
Thank you,

So I assume that I have to put sleep 1 in front of each command ??
and what about echo ?
Smilie
# 6  
Old 10-12-2011
sleep and echo have nothing to do with it. It's just an example.

Did you try my example, and see what it did?

The shell runs lines in order. That's why it waits a second between printing A, B, and C -- sleep pauses a second, and the shell waits for it to end before running the next line.

If you left out all the sleeps it'd still run all three commands in order and wait for each to finish. But it'd happen so quickly you wouldn't see what it was doing.
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 10-12-2011
Got it Thx Smilie!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check same process running 10 times?

At run time Without knowing job name how to check the job running in specific user "ABCD" ,If the running job duplicate more then 10 then script it self send alert message to the users with the process ID name so that will kill the processed to avoid hung issue ,tried below script please check and... (15 Replies)
Discussion started by: Kalia
15 Replies

2. Shell Programming and Scripting

Insert one charactor multiple times in VI

Hi Gurus, I forgot the command which can insert one character multiple times. for example: I need 50 "#" #############... I used the command before, it is very convenient. anybody can help this. thanks in advance. (1 Reply)
Discussion started by: Torhong
1 Replies

3. Shell Programming and Scripting

Running a program multiple times to search pattern and assign structure

Hi all, I have a big file (n.txt) with following pattern: ATOM 1 N SER A 1 122.392 152.261 138.190 1.00 0.00 N ATOM 2 CA SER A 1 122.726 151.241 139.183 1.00 0.00 C TER ENDMDL ATOM 1 N SER A 1 114.207 142.287 135.439 1.00 0.00 ... (3 Replies)
Discussion started by: bioinfo
3 Replies

4. Shell Programming and Scripting

need help using one variable multiple times

I apologize for the title but I am not even sure myself what to call this. I am going to use an example of a pizza delivery. I need to make an interactive script that allows users to order a certain number of pizzas, and then choose what they want on each pizza. Here is my code so far.... ... (1 Reply)
Discussion started by: cstadnyk1
1 Replies

5. Shell Programming and Scripting

Avoid script running multiple times by filelock

Sometimes we need a single instance of a script to run at a time. Meaning, the script itself should detects whether any instances of himself are still running and act accordingly. When multiple instances of one script running, it’s easy to cause problems. I’ve ever seen that about 350 instances... (4 Replies)
Discussion started by: edenCC
4 Replies

6. Shell Programming and Scripting

Doing one thing multiple times

Hi, I wrote a awk line here: awk 'BEGIN {OFS="\t"} {print $0, int(rand()*($2-$1 + 1) + $1) }' filename Basically what it does is that it takes the start (column 1) and stop (column 2) and generates a random # in between start and stop. I want to take this a step further and have it... (2 Replies)
Discussion started by: phil_heath
2 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Crons executed multiple times.

For some reason my crons are being executed twice. Any suggestion?? I'm currently on 5.8 (2 Replies)
Discussion started by: shorty
2 Replies

9. Shell Programming and Scripting

Trying to read data multiple times

I am developing a script to automate Global Mirroring on IBM DS8100's. Part of the process is to establish a global copy and wait until the paired LUN's Out of Sync tracks goes to zero. I can issue a command to display the ouput and am trying to use AWK to read the appropriate field. I am... (1 Reply)
Discussion started by: coachr
1 Replies

10. Shell Programming and Scripting

Trying to read data multiple times

I am developing a script to automate Global Mirroring on IBM DS8100's. Part of the process is to establish a global copy and wait until the paired LUN's Out of Sync tracks goes to zero. I can issue a command to display the ouput and am trying to use AWK to read the appropriate field. I am... (0 Replies)
Discussion started by: coachr
0 Replies
Login or Register to Ask a Question