Skip to main content
Managing the lifecycle and inventory of job schedulers is crucial for maintaining efficient and organized background tasks. BullMQ provides several methods for comprehensive control over your job scheduling environment.

Key Management Methods

upsertJobScheduler

Creates or updates a job scheduler. This is the primary method for scheduler management.
jobSchedulerId
string
required
Unique identifier for the scheduler
repeatOpts
RepeatOptions
required
Repeat configuration (pattern, every, startDate, etc.)
template
JobTemplate
Job template with name, data, and options

removeJobScheduler

Deletes a specific job scheduler from the queue. This is useful when a scheduled task is no longer needed or to clean up inactive or obsolete schedulers.
jobSchedulerId
string
required
ID of the scheduler to remove
result
number
Returns 1 if a scheduler was removed, 0 if no scheduler existed with that ID
Removing a scheduler does not affect jobs that have already been created by that scheduler. Only future job creation is stopped.

getJobScheduler

Retrieves detailed information about a specific job scheduler.
jobSchedulerId
string
required
ID of the scheduler to retrieve
scheduler
JobSchedulerJson
Scheduler details or undefined if not found

getJobSchedulers

Retrieves a list of all configured job schedulers within a specified range. This is invaluable for monitoring and managing multiple job schedulers, especially in systems where jobs are dynamically scheduled.
start
number
default:"0"
Starting index (0-based)
end
number
default:"-1"
Ending index (-1 means all remaining)
asc
boolean
default:"false"
Sort order by next execution time (true = ascending, false = descending)
schedulers
JobSchedulerJson[]
Array of scheduler details

getSchedulersCount

Returns the total number of active job schedulers.
count
number
Number of active schedulers in the queue

Common Management Patterns

Listing All Schedulers

Monitoring Scheduler Status

Updating an Existing Scheduler

Bulk Scheduler Cleanup

Pausing and Resuming Schedulers

BullMQ doesn’t have built-in pause/resume for individual schedulers. You can implement this pattern by removing and re-creating schedulers.

Dashboard Data

Best Practices

1

Use consistent naming conventions

Choose meaningful, hierarchical scheduler IDs:
2

Monitor scheduler health

Regularly check scheduler status and execution times:
3

Clean up completed schedulers

Remove schedulers that have reached their limit:
4

Handle scheduler not found gracefully

Always check for undefined when retrieving schedulers:
5

Document scheduler purposes

Use job data or external documentation to track scheduler purposes:

Troubleshooting

Scheduler Not Creating Jobs

Finding Duplicate Schedulers

Overview

Learn Job Schedulers basics

Repeat Strategies

Understand every, cron, and custom strategies

Repeat Options

Configure scheduler options

RepeatableOptions

API reference

API Reference