from subprocess import call, check_output
processes = check_output("ps -ef|grep python", shell=True)
processes = processes.decode().split("\n")
python_process_id = None
for process in processes:
if "main.py" in process:
python_process = [i for i in process.split(" ") if i is not None and i != ""]
python_process_id = python_process[1]
if python_process_id is None:
raise ValueError("未找到flask process id")
call("kill {0}".format(python_process_id), shell=True)
call("nohup /home/amcuser/my_project/py_env/bin/python /home/amcuser/my_project/icc/main.py & >/dev/null", shell=True)
进程重启脚本示例
最新推荐文章于 2024-01-22 10:00:32 发布