代码拉取完成,页面将自动刷新
#!/usr/bin/python3
import os
import logging
import subprocess
import datetime
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.memory import MemoryJobStore
from apscheduler.executors.pool import ThreadPoolExecutor,ProcessPoolExecutor
def Collect():
current_date = datetime.date.today().strftime('%Y-%m-%d')
subprocess.run(['apt','update'])
subprocess.run(['mkdir','-p','/collect/%s/lists'%(current_date)])
subprocess.run('cp /var/lib/apt/lists/*amd64* /var/lib/apt/lists/*Release /collect/%s/lists/'%(current_date),shell=True)
if __name__ == "__main__":
Collect()
'''
logfile = "/var/log/lists_collect.log"
logging.basicConfig(format='%(asctime)s-%(name)s-%(levelname)s-%(message)s',datefmt='%Y-%m-%d,%H:%M:%S',level=logging.DEBUG,filename=logfile)
jobstores = {'default': MemoryJobStore()}
executors = {'default':ThreadPoolExecutor(1),'processpool':ProcessPoolExecutor(1)}
# job_defaults = {'misfire_grace_time':3600,'coalesce':True,'max_instances':1}
job_defaults = {'max_instances':1}
background_scheduler = BackgroundScheduler(jobstores=jobstores,executors=executors,job_defaults=job_defaults,timezone='Asia/Shanghai')
background_scheduler.add_job(Collect,trigger='cron',id='collect',hour='23',replace_existing=True)
background_scheduler.start()
DBusGMainLoop(set_as_default=True)
loop = GLib.MainLoop()
loop.run()
'''
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。