import psutil,pdb
import subprocess
def get_process_id(process_name):
return
def check_and_start_process(process_name, start_command):
ss=psutil.process_iter()
for proc in psutil.process_iter():
# pdb.set_trace()
# print(proc.pid,proc.cmdline())
if process_name in proc.cmdline():
print(f"Process '{process_name}' is already running.")
return
print(f"Process '{process_name}' is not running. Starting it...")
subprocess.Popen(start_command, shell=True)
# 要檢測(cè)的進(jìn)程名稱
process_name = '*****.py'
# 啟動(dòng)進(jìn)程的命令
start_command = 'nohup **.py >/dev/null 2>&1 &'
check_and_start_process(process_name, start_command)