惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
N
Netflix TechBlog - Medium
C
Check Point Blog
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
腾讯CDC
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
V
V2EX
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
B
Blog

博客园 - 干炸小黄鱼

timex 处理时间戳 gorm-gen go 雪花算法 golang每日一库--协程池库ants golang每日一库--json解析库gjson python高级编程-asyncio python高级编程-condition python高级编程-event python装饰器-自动重试 EAP系统 go实现实现 SECS/GEM 协议 设备通信协议 SECS go项目使用Jenkins进行CICD go操作ES mongo db聚合查询 go如何使用mongodb Apache ShardingSphere paxos and raft (分布式一致性算法) go使用zookeeper分布式锁以及和redis差异 go使用 seata 示例 Alibaba 分布式事务 Seata go中使用saga go中使用TCC示例 分布式事务TCC 熔断器 Hystrix OR Sentinel k8s下部署consul and etcd Consul OR Etcd 【力扣hot100】双指针-盛水最多的容器 【力扣hot100】滑动窗口-最小覆盖子串 shell脚本合集
python中 apscheduler.schedulers.blocking.BlockingSchedule...
干炸小黄鱼 · 2024-08-12 · via 博客园 - 干炸小黄鱼

定时文件目录:
sites.scripts.schedulers 定时器文件
sites.scripts 存放具体定时执行的函数业务 如sites.scripts.backup_data等

import datetime

from apscheduler.schedulers.blocking import BlockingScheduler

from sites.scripts.backup_data import backup_data_task



if __name__ == "__main__":
    scheduler = BlockingScheduler(timezone="Asia/Shanghai")
    next_run_time = datetime.datetime.now() + datetime.timedelta(seconds=5)
    # 定时备份文件
    scheduler.add_job(backup_data_task, "interval", seconds=60 * 60 * 2, next_run_time=next_run_time)
    scheduler.start()

启动定时器:
python -u -m sites.scripts.schedulers