1

I want to be able to accomplish the following. Run script(1)-->sleep 5-->run script(2)-->sleep 5. This pattern needs to continue for the next 30 minutes before running script(3). Once all 3 scripts are run, they need to loop again in the same fashion.

I have no clue what I'm doing, I know it involves a while loop with a counter, etc. I don't know if this is correct and I don't know where to place script3.py. This is what I have so far:

#!/bin/bash
while true;
i=0
until [ i$ -eq 36]
do 
    python script1.py
    sleep 5
    python script2.py
    sleep 5      
    i=$[$i+1]
python script3.py
done

Thanks for any feedback! Damo

2
  • Move python script3.py after the done Commented Oct 11, 2013 at 4:37
  • 2
    If you can't write bash scripts then write your code here in Python! Commented Oct 11, 2013 at 4:37

1 Answer 1

3

I'm kind of surprised this question got so many downvotes. Anyway, this is what you want

#!/bin/bash
while true
do
    begin_time=$(date +%s)
    end_time=$((begin_time + 30*60))
    while [ $(date +%s) -lt $end_time ]
    do
        python script1.py
        sleep 5
        python script2.py
        sleep 5
    done
    python script3.py
 done
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Kurtis, I'm not a programmer and as such have very little experience who asks dumb questions, so I'm not surprised by the downvotes. However, what you suggested works perfectly :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.