Back to Medusa

{metadata.title}

www/apps/resources/app/troubleshooting/scheduled-job-not-running/page.mdx

2.14.21.4 KB
Original Source

import NotRunning from "../_sections/scheduled-jobs/not-running.mdx" import NotRunningWorkerMode from "../_sections/scheduled-jobs/not-running-worker-mode.mdx"

export const metadata = { title: Scheduled Job Not Running on Schedule, }

{metadata.title}

This troubleshooting guide helps you troubleshoot issues when a scheduled job in your Medusa application is not running, or running at unexpected times.

Confirm Job is Set Up Correctly

Make sure that the scheduled job is set up correctly in your Medusa application. Check the following:

  1. The job is created under the src/jobs directory.
  2. The job exports an asynchronous function that performs the task. For example:
ts
import { MedusaContainer } from "@medusajs/framework/types"

export default async function greetingJob(container: MedusaContainer) {
  const logger = container.resolve("logger")

  logger.info("Greeting!")
}
  1. The job exports a config object that has the following properties:
    • name: A unique name for the job.
    • schedule: A string that holds a cron expression or an interval indicating the schedule to run the job.

For example:

ts
export const config = {
  name: "greeting-every-minute",
  schedule: "* * * * *",
}

Job Not Running on Schedule

<NotRunning />

Confirm Worker Mode is Set Up Correctly

<NotRunningWorkerMode />