23 lines
688 B
Python
23 lines
688 B
Python
import datetime,time,os,schedule
|
|
|
|
#filepath = 'E:/safeyunbackup/'+filename
|
|
#backstr = 'C:/PostgreSQL/10/bin/pg_dump -h localhost -U postgres safedb > '+ filepath
|
|
#os.system(backstr)
|
|
#print(filename +'备份成功')
|
|
|
|
def backup():
|
|
os.system('save.bat')
|
|
filename = 'safedb_'+ datetime.datetime.now().strftime("%Y-%m-%d")
|
|
print('pg备份成功--'+ filename)
|
|
|
|
def clearsession():
|
|
os.system('python D:\mysite\manage.py clearsessions')
|
|
print('清除过期session成功--'+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
|
|
|
schedule.every().day.at("01:30").do(backup)
|
|
#schedule.every(6).hour.do(backup)
|
|
|
|
while True:
|
|
schedule.run_pending()
|
|
time.sleep(1)
|