1

Example, there is 1 .py script set with CRON to execute every 5 minutes. What if that script takes more than 5 mins to finish? Would that cause the problem? Would .py program broke?

Is it possible to run 2 (same) script at the time without a collision?

2
  • This is easy to verify, just create an infinite loop and set it up to be run every 1 minute by cron. Verify if it worked, kill the processes and remove the crontab entry.
    – Alex
    Dec 14, 2015 at 22:00
  • What does the script do?
    – muru
    Dec 14, 2015 at 23:37

2 Answers 2

5

cron does not care how many scripts, same or not, you are running. It will just start the task at scheduled time.

So if you are good with running a script second time while the first one is running, there is no problem.

Although it depends on the script but usually unless necessary most of time it might create unusual results due to race conditions created by running multiple instances of the same script simultaneously. To avoid that there are multiple mechanisms that ensure that only one instance of a script is running.

The main point is, if you are good with it, cron won't complain.

1
  • 1
    @BrosCode As you've never accepted an answer on this site before: If this answer helped you, don't forget to click the grey at the left of this text, which means Yes, this answer is valid! ;-) Much better then a thank you!
    – Fabby
    Dec 15, 2015 at 18:09
2

It should execute normally. It is exactly the same case as when you run the same script on different Terminals. The script works on both.

If you don't want this to be the case, then create some conditions in the script so that it waits for the last one to finish.

And as Alex's comment suggest, you can easily test this by having an infinite loop in a script which gets executed by a cron job.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .