First define what “only one node runs the cronjob” means. Preventing simultaneous execution and preventing a repeated business effect are different requirements. A shared scheduler coordinates execution; the operation itself must remain safe after a crash and retry.
Consider a daily invoice job deployed on three NestJS nodes. We want the scheduled work to run, without generating another invoice when a worker restarts.
1. Understand why all nodes start the task
Each application instance registers its own cron callback. At the scheduled time, each can start independently:
