- один работает каждые 1 минуту
- один работает каждые 5 минут
- Другие бегут каждые 10 минут, 1 мин. />
Пример кода для 5-минутного задания: < /p>
import { Cron } from '@nestjs/schedule';
import { Injectable, Logger } from '@nestjs/common';
@Injectable()
export class TasksService {
private readonly logger = new Logger(TasksService.name);
@Cron('*/5 * * * *')
async scheduledHandleCronOld() {
this.logger.log('Old File Processing Job >> Starting scheduled handleCronOld...');
try {
if (this.config.get('SFTP_FILE_FORMAT') === 'OLD') {
await this.handleCronOld(null);
} else {
this.logger.log('Old File Processing Job >> Ended due to config is NEW File Format...');
}
} catch (error) {
this.logger.error(`Old File Processing Job >> Scheduler error: ${error.message}`);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... expectedly
Мобильная версия