分类: LINUX
2014-07-07 10:36:44
1. 时间
前一小时
prehour = datetime.datetime.now() - datetime.timedelta(hours=1)
logdate = prehour.strftime("%F")
loghour = prehour.strftime("%H")
begintime = datetime.datetime.now().strftime("%F %H:%M:%S")
curmin = time.strftime('%M', time.localtime(time.time()))
2. 脚本参数化处理
if len(sys.argv) != 3 :
print "usage " +sys.argv[0] +" game jobid"
exit(1)
note:argv的数量包括脚本名,是argv[0],两个参数,总数就是3个
3. 执行脚本命令
update_cmd = "/usr/bin/python %s %s \"%s\"" % (updatecmd, jobid, info)
status, output = commands.getstatusoutput(update_cmd)
if status != 0:
print "%s failed" % update_zeus_cmd