在AppEngine cron(python)中每天、每周、每月、每年

2024-09-24 22:22:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图设置一个appengine任务,在每天、每周、每月和每年的午夜重复执行,以清除游戏的高分列表。

我的亲信yaml看起来是这样的:

- description: daily clear
  url: /delete?off=10
  schedule: every day 00:00
- description: weekly clear
  url: /delete?off=20
  schedule: every monday 00:00
- description: monthly clear
  url: /delete?off=30
  schedule: every month 00:00
- description: yearly clear
  url: /delete?off=40
  schedule: every year 00:00

每天和每周的工作都可以,但我不知道如何让工作每月和每年都重复。这是the schedule format

对于每个月的工作,我都尝试过“每个月”、“每月一号”等表达方式,但都没有奏效。在cron作业中可以使用这种调度吗?

或者我只需要每天00:00调用清除页面,然后在页面中执行此逻辑并测试当前日期(如果它是周/月/年的开始)?


Tags: 游戏urlyaml列表页面descriptiondeletedaily
2条回答

您链接的文档提供了如何实现所需所有结果的示例。

# Daily:
every day 00:00

# Weekly:
every monday 00:00

# Monthly:
1 of month 00:00

# Yearly:
1 of jan 00:00

我想这样说:

- description: daily clear
  url: /delete/daily
  schedule: every day 00:00
- description: weekly clear
  url: /delete/weekly
  schedule: every monday 00:00
- description: monthly clear
  url: /delete/monthly
  schedule: first of month 00:00
- description: yearly clear
  url: /delete/yearly
  schedule: first of jan 00:00

AFAIK在yaml中不能使用这样的语法,但是需要为每个不同的clear显式地定义一个路由,例如/delete/weekly

相关问题 更多 >