I have two same python file in different location and these scripts will be invoked and executed in random time. If one script is executing, I want other script to wait until that job is finished. How can I get it done?
you can have a global Flag in somewhere like DB and change your code in a way that script1 only runs when flag is True and script2 only runs when flag is set to false. you should change the value of flag in both scripts.
Or you can use Trigger. Trigger script2 from script1 after his work is finished.
Avoid duplicate execution of same python script in different location when invoked by cron