Estoy tratando de implementar una aplicación en mi servidor ELB y activar un trabajo cron cada vez que esto sucede.
¿No estás seguro de cómo hacer que funcione? Aquí está mi configuración a continuación. ¿Alguien puede ayudar?
contenedor.config
container_commands: 01_remove_cron_jobs: command: "rm /etc/cron.d/cron_job || exit 0" 02_start_cron_jobs: command: "cat .ebextensions/batch_job.txt > /etc/cron.d/cron_job && chmod 644 /etc/cron.d/cron_job" leader_only: truelote_trabajo.txt
# The newline at the end of this file is extremely important. Cron won't run without it. * * * * * root npm run batch > /dev/nullpaquete.json
"name": "investor-api", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "nodemon ./src/server.ts", "batch": "nodemon ./src/batch/index.ts" }./src/batch/index.ts
import cron from 'node-cron'; import { fetchHolders, fetchTransactions, updateHistory, } from './schedule.batch'; import { logger } from '../services/winston'; (() => { cron.schedule('1 * * * *', function () { logger.debug('Start fetching holders'); fetchHolders().then(); }); cron.schedule('*/5 * * * *', function () { logger.debug('Start fetching transactions'); fetchTransactions().then(); }); cron.schedule('10 * * * *', function () { logger.debug('Start updating history'); updateHistory().then(); }); })();