REAPI/kill.py
2024-09-29 15:43:18 +08:00

27 lines
711 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# dm_process为keyvalue为具体指令 如call office-convert_call id=1
import time
import os
#import pprint
#import subprocess
#from gevent import monkey; monkey.patch_socket()
#import gevent
def popen(command, bg=False):
string = command
if bg == True:
command = command + ' &'
process = os.popen(command)
output = process.read()
process.close()
return output
# 定时执行进程
def process():
check = 'ps -ef | grep gateway/api.task/cron | grep -v grep |awk \'{print $2}\''
value = int(popen(check))
if value:
popen('kill ' + str(value))
process()