import sys, os, time, subprocess, optparse
from optparse import OptionParser
def runProcess(exe, t):
p = subprocess.Popen(exe)
if p.pid != None:
time.sleep(float(t))
p.terminate()
time.sleep(10)
def main():
usage = "usage: %prog [options]"
parser = OptionParser(usage)
parser.add_option('-e', '--exe', action='store', dest='exe', default=None, help='specify executable')
parser.add_option('-t', '--time', action='store', dest='t', default=None, help='specify time interval (in seconds) for auto-restart')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
(options, args) = parser.parse_args()
if options.exe == None or options.t == None:
parser.print_help()
sys.exit(1)
try:
while(True):
runProcess(options.exe, options.t)
except (KeyboardInterrupt, SystemExit):
print("quitting")
exit(1)
exit(1)
if __name__ == '__main__':
main()
Save the file as "autorefresh.py," install python 3.3, then just enter "py autorefresh.py -e reaper -t 7200" to have it auto-restart in 2 hrs.
LMyyektyV629HbbrSR3WRu9TycnYRgiKXK