I'm currently working on a project that I want to restart and rerun every 10 minutes. So I created this test file to see if I could get it working.
import sys
import os
import sched
import time
print("Hello")
s = sched.scheduler(time.time, time.sleep)
def restart_program(sc):
python = sys.executable
os.execl(python, python, * sys.argv)
s.enter(5, 1, restart_program, (sc,))
s.enter(5, 1, restart_program, (s,))
s.run()
So I want this program to restart every 5 seconds. In this case it would print "Hello!". But when i run it, it just prints once and never restarts.
How would I make it restart regulary?