Skip to content

@domusjs/cron — Introduction

The Cron Module in DomusJS provides a simple, pluggable scheduler to handle repetitive or timed tasks inside your backend application.

✅ Built on top of node-cron, it enables you to run background tasks at specific intervals, such as:

  • Cleaning expired data.
  • Synchronizing external services.
  • Sending periodic reports.
  • Triggering domain commands at regular times.

In real-world applications, you often need to run logic outside the request/response cycle, such as:

ScenarioShould Use Cron?
Run a task every hour✅ Yes
Perform cleanup once a day✅ Yes
Process thousands of items in the background❌ No (use jobs)
React to external events or publish/subscribe❌ No (use Event Bus)

✅ The Cron Module is ideal for infrastructure-level automation where timing matters.


Pluggable & Modular → Register jobs only from the contexts that own them.
Centralized Scheduler → Avoid duplicate or scattered scheduling logic.
Integration-ready → Works smoothly with DomusJS Command Bus and other modules.