1

I have a python script that I want to execute every 10 minutes. However it takes 30 minutes to complete that script. (It's a script to query approx 1400+ servers) .If I let it execute every 10 minutes will it terminate the already running cron job or will it just start a new one and leave the other one running?

If it stops the other job is there a way I am able to make it run multiple at the same time?

If it has any help this is my command for the cron job which is scheduled to run every 10 minutes

cd /home/forge/****.**********.*** && ./status.py

Thanks in advance.

Dinesh Pundkar
  • 4,160
  • 1
  • 23
  • 37
Timo
  • 87
  • 3
  • 13
  • Doesn't running overlapping copies of this script (as you seem to want to do) just make things run ever slower, eventually running the computer into the ground? Maybe you want to re-thinkhow your script works and/or how you want to use it. – Scott Hunter Aug 26 '16 at 14:08
  • @ScottHunter At max it would overlap 3 at the same time. And it might slow it down a bit but we have a "Dedicated Server" for this task (With dedicated server i mean a server dedicated for this task) and has no performance hit on our main server where the clients will access it – Timo Aug 26 '16 at 14:12
  • 1
    Make a short script that launch your real script in background, thus cron will only see the short one... – Jean-Baptiste Yunès Aug 26 '16 at 14:59

1 Answers1

2

If a later job stops an older job, should be handled in the executed job description. But if your job runs for 30minutes, you will see two status.py jobs after 10minutes, and three after 20min. When the first job terminates at minute 30, another one will be started and you still have three jobs, then at minute 40 the second job terminates and another one is started, so you will always have three running status.py in the end.

Cron, as most unix tools, does not care if you do things wrong. The system just tries to fullfill what you told it to do.

ikrabbe
  • 1,909
  • 12
  • 25
  • 1
    **NO** at minute 40 you will have only three jobs! In the long run at minute 10*k you launch one job and one died (launched 30 minutes before). Accumulation appears only at the beginning. – Jean-Baptiste Yunès Aug 26 '16 at 14:57