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)
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)