123456789101112131415161718192021222324252627 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import time
- import os
- timeSleep = 15
- 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():
- command = 'php /www/api/src/dai/seller/index.php \'{"l":"task.cron"}\' 1>/dev/null 2>&1 &'
- check = 'ps -ef | grep task.cron | grep -v grep | wc -l'
- i = 0
- while 1:
- value = int(popen(check))
- if value == 0:
- popen(command)
- time.sleep(timeSleep)
- process()
|