加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
copy_lists.py 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
沈亚峰 提交于 2024-06-21 15:20 . initial commit
#!/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()
'''
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化