python3 定时重启服务

网友投稿 1195 2022-08-27

python3 定时重启服务

python3 定时重启服务

import os import time import time import datetime import codecs def get_min(): return int( time.strftime( ' %M ', time.localtime(time.time())) ) def get_hour(): return int( time.strftime( ' %H ', time.localtime(time.time())) ) def get_current_time(): return ( str(datetime.datetime.now().year) + ' - ' + str(datetime.datetime.now().month) + ' - ' + str(datetime.datetime.now().day) + " " + time.strftime( ' %H:%M:%S ',time.localtime(time.time())) ) def writelog(content): print(content) f = codecs.open( ' reboot.log ', ' a ', ' utf-8 ') f.write(content) f.writelines( ' \r\n ') f.flush() def rebootservice(): os.system( ' net stop spooler ') time.sleep(1) os.system( ' net start spooler ') while True: print(get_current_time()) if ( get_min() == 24 and get_hour() == 12 ): writelog( " 重启服务时间: " + get_current_time()) rebootservice() time.sleep(60) time.sleep(10)

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如何调试崩溃程序(一) 更改调试器,转存文件
下一篇:Visual Studio原生开发的10个调试技巧(一)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~