Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cron.schedule('0 9 * * 1-5', fn) returns a invalid Next Run date #482

@mfried40

Description

@mfried40

I have set up a cron job that's supposed to run on weekdays at 9AM

const nineAmJob = cron.schedule('0 9 * * 1-5', async () => {
       logger.info("Starting 9 AM Job");
       ...
       logger.info("Completed 9 AM Job");
       logger.info(`Next run will be ${nineAmJob.getNextRun()}`)
});

const status = nineAmJob.getStatus();
const nextRun = nineAmJob.getNextRun();
logger.info(`Successfully started service, status is ${status}`);
logger.info(`Next run will be: ${nextRun}`)

Today is Fri Aug 08 2025

it worked fine today in the morning but now it's returning a next run date of Mon Sep 01 2025 09:00:00 GMT-0400
I expect the next run date to be Mon Aug 11 2025 09:00:00 GMT-0400

From what i've tried it seems like the day of the month is interpreted as 1 when using a wildcard, when i set it to 0 9 11 * 1-5 it does return the next Monday

here are the logs of todays run in the morning

7|notify   | 2025-08-08T13:00:00.123Z info:     Starting 9 AM Job
...
7|notify   | 2025-08-08T13:00:01.356Z info:     Completed 9 AM Job
7|notify   | 2025-08-08T13:00:01.363Z info:     Next run will be Mon Sep 01 2025 09:00:00 GMT-0400 (Eastern Daylight Time)
7|notify   | 2025-08-08T13:00:01.503Z debug:    sent heartbeat - 200

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions