定时执行脚本

Reading time ~1 minute

用python执行shell脚本,奇数分钟执行


from datetime import date, datetime, timedelta
from time import clock as now
import commands
import decimal
import urllib2
import json
import datetime
import time

min = time.strftime('%M', time.localtime())
m = int(min)
command_start = "test"
command_stop = "stop"
if m % 2 == 0:
    a, b = commands.getstatusoutput(command_start)
    print 'start ', a
else:
    a, b = commands.getstatusoutput(command_stop)
    print 'stop ', a


 

taste是个玄学

Published on November 16, 2022

印度工人

Published on August 30, 2022