0

I am in the process of creating a Python program (lets call it Program1), which will terminate randomly. I need another program to check if Program1 has been terminated, and if so, to restart it after a given amount of time. Should I use another Python program to do this, or is there a way this can be done in Windows e.g. similar to a cron job?

From what I understand, you can use sys.exit(), exit() and quit() to kill a Python program, but do all of these also kill all other running Python programs?

Thanks

badcoder
  • 3,624
  • 5
  • 32
  • 33
  • 1
    *do all of these also kill all other running Python programs?* they all do not – Tim May 08 '14 at 21:45

1 Answers1

1

Reliably determining whether a specific program is still running or not can be done in multiple ways.

A good way to do so would be using a specific lock file. You can find how to do this in Python described in this thread.

To answer the second part of your question: sys.exit(), exit() and others will only stop the currently running Python process, not any others that might be running concurrently.

Community
  • 1
  • 1
ChristopheD
  • 112,638
  • 29
  • 165
  • 179