Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. #!/home/pi/botenv/botvenv/bin python
  2. import time, subprocess
  3.  
  4. COMMAND=['/home/pi/botenv/bot/test.py']
  5. LOGFILE='/home/pi/botenv/bot/restart.txt'
  6.  
  7. def writelog(message):
  8.     with open(LOGFILE,'a') as f:
  9.         f.write("{0} {1}\n".format(time.asctime( time.localtime(time.time())),
  10.                                    message))
  11.  
  12. writelog("Starting")
  13. while True:
  14.     rc = subprocess.call(COMMAND)
  15.     if rc >= 0:
  16.         writelog("Exited with {0} status".format(rc))
  17.     else:
  18.         writelog("Exited on signal {0}".format(0-rc))
  19.     writelog("Restarting")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement