diff --git a/intervalexec.py b/intervalexec.py new file mode 100644 index 0000000..adb4727 --- /dev/null +++ b/intervalexec.py @@ -0,0 +1,26 @@ +import subprocess +import sys +import time + + + +def run(args): + subprocess.run(args, check=True) + + +def main(args): + interval_secs = float(args[0]) + exec_args = args[1:] + while True: + start_time = time.time() + next_time = start_time + interval_secs + run(exec_args) + now = time.time() + delay = next_time - now + if delay > 0.01: + time.sleep(delay) + + + +if __name__ == '__main__': + main(sys.argv[1:])