Skip to content

Instantly share code, notes, and snippets.

@spenkk
Created January 24, 2020 23:47
Show Gist options
  • Save spenkk/3f4f12270416d2eff68822da8d3037cd to your computer and use it in GitHub Desktop.
Save spenkk/3f4f12270416d2eff68822da8d3037cd to your computer and use it in GitHub Desktop.
Restart process if it's not running
import psutil
import os
import time
while True:
time.sleep(15)
def checkIfProcessRunning(processName):
#Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False;
if checkIfProcessRunning('vulnserver'):
print('[*] VulnServer is running')
else:
print('[-] VulnServver is not running! Starting it now.')
os.system("start /b C:\\vulnserver.exe")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment