linux 操作系统下进程启停控制脚本

 

#! /usr/bin/env python
import sys,os,subprocess,time
strIndex = "./Main"
if len(sys.argv) < 2:
print """Input arguments to start
eg: FLT--->./MainFLT
eg: FLT FLS FLA--->./MainFLT ./MainFLS ./MainFLT
eg: ALL-->start all the server"""
strServerExc = ''
bAllFlag = 'all' in sys.argv or 'All'in sys.argv or 'ALL' in sys.argv

if len(sys.argv) > 1:
if bAllFlag:
textlist = os.popen('ls -a|grep Main')
lstMainTemp = textlist.readlines()
for item in lstMainTemp:
print item.strip('\n')
os.popen("./%s &"%(item.strip('\n'))).close()
time.sleep(0.3)
else:
for strServerName in sys.argv[1:]:
strServerExc = "%s%s &"%(strIndex,strServerName)
print strServerExc
os.popen(strServerExc).close()
time.sleep(0.3)

你可能感兴趣的:(linux,python,linux,脚本,python,进程同时启动)