How do I write a cron scheduler with NestJS so that it triggers every day at 3 am?
@Cron('10 * * * * *')
async handleCron() {
const country = await this.countryRepo.find();
country.map(async (value) => {
...doing something
});
}
How do I write a cron scheduler with NestJS so that it triggers every day at 3 am?
@Cron('10 * * * * *')
async handleCron() {
const country = await this.countryRepo.find();
country.map(async (value) => {
...doing something
});
}
@Cron('0 0 3 * * *')
// | | | | | | every day of week
// | | | | | every month
// | | | | every day of month
// | | | at 3 hours
// | | at 0 minutes
// | at 0 seconds
https://docs.nestjs.com/techniques/task-scheduling#declarative-cron-jobs