I'm trying to set an appengine task to be repeated at midnight of every day, week, month, and year, for clearing a high score list for a game.
My cron.yaml looks like this:
- 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
Daily and weekly jobs are OK, but I can't figure out how to make a job repeat every month and year. This is the schedule format.
For each month job, I've tried expressions like 'every month', '1st of month', etc, but nothing did work. Is this type of schedule possible in cron jobs?
Or do I need to just invoke the clearing page just daily at 00:00, and do this logic in page and test current date, if it's the start of week/month/year?
The docs you link to give examples of how you could achieve all of the results you want.
# Daily:
every day 00:00
# Weekly:
every monday 00:00
# Monthly:
1 of month 00:00
# Yearly:
1 of jan 00:00
I would go with something like this:
- 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 you can't use a syntax like this /delete?off=30
in yaml
but you need to define a route explicitly for every different clear with /delete/weekly
for example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With