关于重启系统服务
来源:互联网 发布:fc2最新域名网站 编辑:程序博客网 时间:2024/04/30 09:46
上周写的挫挫的重启服务的代码,只能重启服务,连异常处理都没有,很挫啊很挫
import os
import time
import threading
from time import gmtime, strftime
lock = threading.Lock()
class restart_service():
def restart_kisaas_service(self):
while True:
# make sure the service is start
print "[start service]"
print strftime("%a, %d %b %Y %H:%M:%S", gmtime())
lock.acquire()
os.system("net start /"Kingsoft Antivirus Client Communication Service/"")
lock.release()
# wait for start
time.sleep(10)
# stop kisaas service
print "[stop service]"
print strftime("%a, %d %b %Y %H:%M:%S", gmtime())
lock.acquire()
os.popen("net stop /"Kingsoft Antivirus Client Communication Service/"")
lock.release()
pRun = restart_service()
pRun.restart_kisaas_service();
sc能更好的处理,不用写中间的等待10s,但是程序还没写出来。。。
sc stop wuauserv
sc query wuauserv
sc start wuauserv
sc query wuauserv
先记录这么多,sc可以知道服务的状态,很方便
- 关于重启系统服务
- 4#linux系统重启Oracle服务
- window系统 Putty 重启git服务
- Linux系统重启network服务失败
- 关于安卓开发系统重启
- VC++ 系统服务如何让服务进程结束后依赖windows自身把服务重启
- 重启系统的时候自动启动oracle服务
- java转义和linux系统重启服务
- linux系统重启httpd服务报错的解决方法
- linux系统下ubuntu重启apache服务命令
- 重启部署在Linux系统下的tomcat服务
- linux系统下ubuntu重启apache服务命令
- linux系统,启动、停止、重启crontab服务
- linux系统下ubuntu重启apache服务命令
- windows下redis作为系统服务如何重启
- 关于服务停止或重启失败--适用于银医通项目
- 重启IIS服务
- 重启vsftp服务
- Note
- 美国Android占28%份额 摩托Droid最受欢迎
- Myeclipse8.0下配置Spket
- rhce之路--linux的基本命令
- 在eclipse中生成英文的javadoc(转自:http://zyp731.javaeye.com/blog/98432)
- 关于重启系统服务
- 数据库方面常见面试题
- 关于FormView在编辑模板下找不到控件的问题
- 求助 SUM 和ROUP BY 的使用方法。感激不尽~!!![
- MySQL常用操作语句
- 系统引导管理器GRUB
- MySql 的unique key 与 primary key
- magento -- 正式发布网银在线Motopay信用卡站内支付收款模块
- A herf="#" 的问题