Skip to content
Cron Expression Generator

node-cron cron format

node-cron Expression Generator

Build and check schedules for cron.schedule() in the node-cron package for Node.js and JavaScript. node-cron takes five fields, or six with seconds first, and accepts month and weekday names. Version 4.6 also reads L, W, # and ?. Unlike crontab, a job runs only on days that match both day fields.

Cron expression translator and generator

Format
Valid

5 fields, or 6 with seconds first. Both day fields must match; write steps as */5 or 5-59/15. L W # need node-cron 4.6.

English

At 8:30 AM, Monday through Friday.

العربية

في تمام الساعة 8:30 ص، من الإثنين إلى الجمعة.

    Quick presets

    Visual cron generator

    Pick options for each field — the expression above updates instantly.

    Next 5 executions

    Local time:

      Cheat sheet

      *
      Any value
      ,
      List — 1,15,30
      -
      Range — 1-5
      /
      Step — */10
      ?
      No specific value (day fields)
      @daily
      Macro for 0 0 * * *
      L
      Last day of the month, or last weekday — 6L
      W
      Nearest Monday–Friday — 15W
      #
      Nth weekday — 6#3
      22-2
      Range that wraps past the end — 10 PM to 2 AM

      node-cron syntax

      A node-cron expression has five fields, or six when you add seconds at the start. With five fields the job runs at second 0:

      FieldAllowed valuesSpecial characters
      Second0–59 (optional, comes first), - * /
      Minute0–59, - * /
      Hour0–23, - * /
      Day of month1–31, - * ? / L W
      Month1–12 or names (JAN, January), - * /
      Day of week0–7 or names (0 and 7 = Sunday), - * ? / L #

      Special characters

      SymbolMeaning
      /Steps, written after * or a range: */10 or 5-59/15. A bare start value such as 5/15 is rejected.
      -Ranges. Since 4.6 a reversed range wraps around, so 22-2 in the hour field runs from 22:00 to 02:59; older versions quietly swap it to 2-22.
      LIn day-of-month, L is the last day of the month (4.3+) and L-3 three days before it (4.6+). In day-of-week, 5L is the last Friday of the month (4.5+).
      WThe weekday nearest to a date: 15W, or LW for the last weekday of the month (4.6+).
      #The nth weekday of the month: 1#1 is the first Monday (4.5+).
      ?Same as *, accepted in the day fields so that Quartz-style expressions parse (4.6+).

      node-cron cron examples

      Click an expression to load it into the generator above.

      ExpressionSchedule
      Every second.
      Every 10 seconds.
      Every 5 minutes.
      At 8:30 AM, Monday through Friday.
      At 9:00 AM, Monday through Friday.
      Every 15 minutes, between 10:00 PM and 2:59 AM.
      At 12:00 AM, on the last day of the month.
      At 9:00 AM, 3 days before the last day of the month.
      At 9:00 AM, on the first Monday of the month.
      At 5:00 PM, on the last Friday of the month.
      At 12:00 AM, on day 13 of the month, but only if that day is a Friday.
      At 12:00 AM.

      How node-cron differs from Linux crontab

      Use it in Node.js

      Schedule a function with cron.schedule(). In node-cron 4 the task starts right away, and the options set the time zone and skip a run while the last one is still busy:

      import cron from 'node-cron';
      
      const task = cron.schedule('0 30 8 * * 1-5', async () => {
        await sendDailyReport();
      }, {
        name: 'daily-report',
        timezone: 'Asia/Riyadh',
        noOverlap: true,
      });
      
      cron.validate('0 30 8 * * 1-5'); // true
      task.getNextRuns(3);             // the next three run dates (4.4+)

      node-cron 3 reads some expressions differently: its steps keep only values divisible by the step, so 5-59/15 fires at :15, :30 and :45 rather than :05, :20, :35 and :50. Run npm ls node-cron to see which version you have.

      Frequently asked questions

      How do I run a node-cron job every 10 seconds?

      Add a seconds field at the start: cron.schedule('*/10 * * * * *', task). With five fields node-cron runs at second 0, so * * * * * fires once a minute.

      Which node-cron version supports L, W and #?

      L in day-of-month arrived in 4.3, # and 5L in 4.5, and W, L-n and ? in 4.6, which also made reversed ranges such as 22-2 wrap around. node-cron 3 has none of them. The generator warns when an expression needs a newer version.

      How do I set the time zone in node-cron?

      Pass an IANA name in the options: cron.schedule('0 8 * * *', task, { timezone: 'Asia/Dubai' }). Without it, node-cron uses the time zone of the Node.js process.

      Do these expressions work in other JavaScript cron libraries?

      Most Node.js schedulers, such as the cron package and Croner, share the five- and six-field layout, but details differ, including how the two day fields combine and which special characters work. Test the expression with the library you use; this generator follows node-cron.

      Cron generators for other platforms

      Browse all cron expression examples →