标签:
import sys import os import subprocess import time start = time.time() f=open(‘data.log‘,‘a‘) sys.stdout=f p = subprocess.Popen((‘/bin/sh‘,‘-c‘,‘curl www.baidu.com -o /dev/null‘), stdout=sys.stdout, stderr=subprocess.STDOUT)while 1: end=time.time() #print end-start if end-start>30: p.terminate() break time.sleep(1) print "popen.pid:%s,exit successful"%p.pid f.close()
标签:
原文地址:http://www.cnblogs.com/saryli/p/5025875.html