docs: document scheduled jobs interval (#13350)

This commit is contained in:
Shahed Nasser
2025-08-29 15:14:26 +03:00
committed by GitHub
parent 7b1028e5ae
commit f39ba53fd3
26 changed files with 1471 additions and 24 deletions

View File

@@ -0,0 +1,40 @@
If you have a scheduled job that is configured with a cron expression, it may not run at the expected times sometimes.
## Why this Happens
When a scheduled job is configured with a cron expression, it will only run when the specified time is reached.
So, if the events system is busy and the specified time is missed, the job will not run until the next scheduled time.
---
## How to Fix it
If you prioritize running your scheduled jobs consistently over precise timing, consider using a scheduled job interval instead.
By using an interval, the job will run after a defined duration, regardless of the system's state.
For example, to run a scheduled job every minute, you can set the interval to 60000 milliseconds (1 minute):
```ts highlights={[["12"]]}
import { MedusaContainer } from "@medusajs/framework/types"
export default async function greetingJob(container: MedusaContainer) {
const logger = container.resolve("logger")
logger.info("Greeting!")
}
export const config = {
name: "greeting-every-minute",
schedule: {
interval: 60000 // 1 minute
}
}
```
---
## Additional Resources
- [Set Interval for Scheduled Jobs](!docs!/learn/fundamentals/scheduled-jobs/interval)

View File

@@ -0,0 +1,9 @@
import NotRunning from "../_sections/scheduled-jobs/not-running.mdx"
export const metadata = {
title: `Scheduled Job Not Running on Schedule`,
}
# {metadata.title}
<NotRunning />