NestJS - Task Scheduling - Prevent running the same Job in parallel in identical service instances in K8s
You need to use the .spec.concurrencyPolicy
field in your Cron Job spec and set it to Forbid
, to prevent concurrent runs of the same job.
See the Concurrency policy chapter in this k8s doc: https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/