payload
payload copied to clipboard
In the job types, the cron example is wrong
Documentation Issue
In AutorunCronConfig, this is the jsdoc comment for the cron field: [source]
export type AutorunCronConfig = {
/**
* The cron schedule for the job.
* @default '* * * * *' (every minute).
*
* @example
* ┌───────────── (optional) second (0 - 59)
* │ ┌───────────── minute (0 - 59)
* │ │ ┌───────────── hour (0 - 23)
* │ │ │ ┌───────────── day of the month (1 - 31)
* │ │ │ │ ┌───────────── month (1 - 12)
* │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
* │ │ │ │ │ │
* │ │ │ │ │ │
* - '* 0 * * * *' every hour at minute 0
* - '* 0 0 * * *' daily at midnight
* - '* 0 0 * * 0' weekly at midnight on Sundays
* - '* 0 0 1 * *' monthly at midnight on the 1st day of the month
* - '* 0/5 * * * *' every 5 minutes
* - '* * * * * *' every second
*/
cron?: string
}
All the examples have a * in seconds place. However, that means "run every second", hence all the descriptions are wrong.
| cron | description | actual meaning |
|---|---|---|
| * 0 * * * * | ❌ every hour at minute 0 | every second, at 0 minutes past the hour |
| * 0 0 * * * | ❌ daily at midnight | every second between 12:00 AM and 12:01 AM |
| * 0 0 * * 0 | ❌ weekly at midnight on Sundays | every second between 12:00 AM and 12:01 AM, only on Sunday |
| * 0 0 1 * * | ❌ monthly at midnight on the 1st day of the month | every second between 12:00 AM and 12:01 AM, on day 1 of the month |
| * 0/5 * * * * | ❌ every 5 minutes | every second, on minutes divisible by 5 |
| ✅ every second | every second |
The correct examples should have 0 in the seconds place, except for the last one.
Hey! I've opened a PR to fix this issue here: https://github.com/payloadcms/payload/pull/17654
I already did open a PR shortly after making the issue.