Nov-24-2021, 02:23 PM
How do I run my script proces1.py and process2.py into a single script to check if both the process are running and if so kill and restart the process again(I am passing arguments seperately in both the script need to achieve this from one script)
#Process1.py for process in psutil.process_iter(): if (process.name().startswith('python3')) and ("new_scene" in process.cmdline()[1]): print('Process found') process.kill() time.sleep(5) cmd='python3 /Desktop/Test/Script/new/new_scene.py --run /Desktop/Test/Script/new/scenario/examples' subprocess.call(cmd + sys.argv[1],shell=True) break else: print('Process not found')
#Process2.py for process in psutil.process_iter(): if (process.name().startswith('python3')) and ("Demo" in process.cmdline()[1]): print('Process found') process.kill() time.sleep(5) cmd='python3 /Desktop/Test/Script/new/Demo.py --run /Desktop/Test/Script/new/scenario/examples' subprocess.call(cmd + sys.argv[1],shell=True) break else: print('Process not found')