From 850e10aefb1fba3cbd18b07f0b44085bff85c4ad Mon Sep 17 00:00:00 2001 From: wuzhaomin Date: Wed, 26 Jun 2024 14:46:41 +0800 Subject: [PATCH] The pid function is added to the conf check.py file --- common/conf_check.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/common/conf_check.py b/common/conf_check.py index 8bad7b3..3c1055c 100644 --- a/common/conf_check.py +++ b/common/conf_check.py @@ -1,3 +1,18 @@ # -*- coding:utf-8 -*- #!/usr/bin/env python -# cython:language_level=3 \ No newline at end of file +# cython:language_level=3 +from common.command import Command + +class ConfCheck: + def pid(process): + ''' + check pid exist or not, return pid or null + ''' + get_pid_cmd = "ps -ef | grep {} | grep -v grep | awk '{{print $2}}'".format(process) + pid_list = Command.cmd_run(get_pid_cmd).split("\n") + pid_list.pop(0) + pid_list.pop(-1) + if len(pid_list) != 0: + return pid_list[0] + else: + return '' -- Gitee