1

I have a Python script that can run anywhere from 10 seconds to 5 minutes.

I need a scheduler that can spawn the job, then after the job is finished, wait 15 minutes, then run the job again etc.

  • No concurrency, just one instance of the job.
  • After the job is finished (not started!) there must be a wait period of 15 minutes.
  • Linux machine.
3
  • 1
    Any reason you're not using cron? Commented Mar 1, 2012 at 2:23
  • I haven't found in the documentation how to batch the job AFTER the current running job is finished, i.e. not in fixed intervals. Any pointers? Commented Mar 1, 2012 at 2:38
  • That's an odd requirement to have and something I don't know how to do in cron. The answer below with the little bash script would work fine or the equivalent logic in your python code. That's actually a pretty common approach for apps that do any polling. Another approach would be for your python script to reschedule itself as it finishes for 15 minutes later using the unix at command and the time module to calculate an offset. Commented Mar 1, 2012 at 3:22

1 Answer 1

3

You could use a bash script to do that. Invoke the program then after it finishes sleep for 15 minutes.

while true; do
    python myprogram.py
    sleep 900
done
Sign up to request clarification or add additional context in comments.

Comments

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.