NestJS · Junior · Question 59 of 75
How do you run a method on a schedule, e.g. every night?
- 1Nest can't schedule tasks
- ✓Correct answer: With
@nestjs/scheduleand the@Cron('0 3 * * *')decorator - 3With
setIntervalin the controller
Explanation
Remember that with several instances each one runs the cron. Use a lock or a queue for jobs that must run once.