python - ensure script is activated only once
问题 I'm writing a Python 2.7 script. In summary, this script is being run every night on Linux and activates several processes. I'd like to ensure this script is not run multiple times in parallel (basically trying to mimic Singleton pattern but on application level) . Code Example def main(): # before doing anything, I'd like to know whether this # script was activated and alive. # if so, error out # do something if __name__ == "__main__": main() Suggestion The naive solution would be to create