#!/usr/bin/env python # -*- coding: utf-8 -*- import time import os 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 task.cron | grep -v grep |awk \'{print $2}\'' value = int(popen(check)) if value: popen('kill ' + str(value)) process()