linux下python多线程,python多线程 - eddy_linux的个人页面 - OSCHINA - 中文开源技术交流社区...

#!/usr/bin/env python

# encoding: utf-8

#  17.51/52:

#

import os

import threading

import sys

def execCmd(cmd):

try:

os.system(cmd)

except Exception, e:

print '%s\t 运行失败,失败原因\r\n%s' % (cmd,e)

if __name__ == '__main__':

start_cmds = [

#            ' su - tomcat -c "/data/program/payment/payment-ac/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-account/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-agent/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-ams/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-business/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-channel/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-channel-ota/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-channel-realnameAuth/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-cm/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-cms/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-fastdfs/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-mas/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-order/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-pe/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-pss/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-rcs/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-route/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-security/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-settle/bin/start.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-tasks/bin/start.sh" ',

]

stop_cmds = [

#            ' su - tomcat -c "/data/program/payment/payment-ac/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-account/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-agent/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-ams/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-business/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-channel/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-channel-ota/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-channel-realnameAuth/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-cm/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-cms/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-fastdfs/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-mas/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-order/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-pe/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-pss/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-rcs/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-route/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-security/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-settle/bin/stop.sh" ',

#            ' su - tomcat -c "/data/program/payment/payment-tasks/bin/stop.sh" ',

]

status_cmds = [

#            ' ps -ef | grep "/data/program/payment/payment-ac" ',

#            ' ps -ef | grep "/data/program/payment/payment-account" ',

#            ' ps -ef | grep "/data/program/payment/payment-agent" ',

#            ' ps -ef | grep "/data/program/payment/payment-ams" ',

#            ' ps -ef | grep "/data/program/payment/payment-business" ',

#            ' ps -ef | grep "/data/program/payment/payment-channel" ',

#            ' ps -ef | grep "/data/program/payment/payment-channel-ota" ',

#            ' ps -ef | grep "/data/program/payment/payment-channel-realnameAuth" ',

#            ' ps -ef | grep "/data/program/payment/payment-cm" ',

#            ' ps -ef | grep "/data/program/payment/payment-cms" ',

#            ' ps -ef | grep "/data/program/payment/payment-fastdfs" ',

#            ' ps -ef | grep "/data/program/payment/payment-mas/bin" ',

#            ' ps -ef | grep "/data/program/payment/payment-order" ',

#            ' ps -ef | grep "/data/program/payment/payment-pe/bin" ',

#            ' ps -ef | grep "/data/program/payment/payment-pss" ',

#            ' ps -ef | grep "/data/program/payment/payment-rcs" ',

#            ' ps -ef | grep "/data/program/payment/payment-route" ',

#            ' ps -ef | grep "/data/program/payment/payment-security" ',

#            ' ps -ef | grep "/data/program/payment/payment-settle" ',

#            ' ps -ef | grep "/data/program/payment/payment-tasks" ',

]

if sys.argv[1] == 'start':

threads = []

for cmd in start_cmds:

th = threading.Thread(target=execCmd, args=(cmd,))

th.start()

threads.append(th)

for th in threads:

th.join()

elif sys.argv[1] == 'stop':

threads = []

for cmd in stop_cmds:

th = threading.Thread(target=execCmd, args=(cmd,))

th.start()

threads.append(th)

for th in threads:

th.join()

elif sys.argv[1] == 'status':

threads = []

for cmd in status_cmds:

th = threading.Thread(target=execCmd, args=(cmd,))

th.start()

threads.append(th)

for th in threads:

th.join()

elif sys.argv == '-h':

print 'python 17_improper_update.py start|stop|status'

else:

print 'python 17_improper_update.py start|stop|status'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值