1 ---
2 sidebar_label: "scheduled-job-schedule-valid-cron"
3 ---
4
5 export const metadata = {
6 title: `scheduled-job-schedule-valid-cron - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires a scheduled job's `config.schedule` string to be a valid cron expression.
12
13 ## Severity
14
15 `error`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 This rule targets files in your project's `src/jobs` directory. It reports a `config.schedule` whose string value isn't a valid cron expression. Interval-based schedules, such as `{ interval: 60000 }`, aren't checked.
20
21 The following code is reported by the rule:
22
23 ```ts title="src/jobs/sync-products.ts"
24 export const config = {
25 name: "sync-products",
26 schedule: "not-a-cron",
27 }
28 ```
29
30 Instead, use a valid cron expression:
31
32 ```ts title="src/jobs/sync-products.ts"
33 export const config = {
34 name: "sync-products",
35 schedule: "0 0 * * *",
36 }
37 ```
38
39 ## Why it's Important
40
41 Medusa uses the `schedule` value to determine when to run the job. An invalid cron expression means the job is never scheduled correctly.
42
43 Learn more in the [Scheduled Jobs documentation](!docs!/learn/fundamentals/scheduled-jobs).
44
45 ## Fixable
46
47 This rule isn't auto-fixable.