LogoRobo.js

Cron expressions

Learn the cron expression format used by @robojs/cron.

Cron expressions define when a job runs. The plugin uses the croner library, which supports a six-field format with seconds precision.

Format

A cron expression consists of six fields separated by spaces:

┌──────── second (0-59)
│ ┌────── minute (0-59)
│ │ ┌──── hour (0-23)
│ │ │ ┌── day of month (1-31)
│ │ │ │ ┌ month (1-12)
│ │ │ │ │ ┌ day of week (0-6, Sunday = 0)
│ │ │ │ │ │
* * * * * *

The seconds field is optional. When only five fields are provided, they represent minute hour day-of-month month day-of-week (the standard cron format).

Special characters

CharacterMeaningExample
*Every value* * * * * * — every second
*/NEvery N units*/5 * * * * * — every 5 seconds
N,MSpecific values0,30 * * * * * — at second 0 and 30
N-MRange of values0-5 * * * * * — seconds 0 through 5
N-M/SRange with step0-30/10 * * * * * — every 10 seconds from 0 to 30

Common examples

ExpressionSchedule
* * * * * *Every second
*/5 * * * * *Every 5 seconds
*/30 * * * * *Every 30 seconds
0 * * * * *Every minute (at second 0)
0 */5 * * * *Every 5 minutes
0 */15 * * * *Every 15 minutes
0 */30 * * * *Every 30 minutes
0 0 * * * *Every hour
0 0 */2 * * *Every 2 hours
0 30 * * * *Every hour at minute 30
0 0 0 * * *Daily at midnight
0 0 12 * * *Daily at noon
0 30 14 * * *Daily at 2:30 PM
0 0 9 * * 1-5Weekdays at 9 AM
0 0 0 * * 0Every Sunday at midnight
0 0 0 1 * *First of each month at midnight
0 0 0 1 1 *January 1 at midnight

Tips

  • Seconds precision. Unlike standard Unix cron (five fields), this plugin supports a sixth field for seconds. Use it for sub-minute schedules.
  • System timezone. Jobs run in the system's local timezone. Keep this in mind when scheduling across time zones.
  • Prefer Patterns. For most schedules, the Patterns helper is easier to read and less error-prone than raw expressions.
  • Validate expressions. Invalid expressions throw an error at job creation time. Use Crontab Guru to verify your expressions (note: Crontab Guru uses five-field format without seconds).

Next Steps

On this page