from time import sleep
import os
process_name = 'main.py'
def process_exists():
call = 'ps ax | grep %s' % process_name
if not process_name in call:
return True
while True:
try:
a = process_exists()
if a != True :
os.system('python3 '+process_name)
sleep(2)
except KeyboardInterrupt:
break