Files
planilla/worker/cron-worker.js
josedario87 b6d7759b30
Some checks failed
build-and-deploy / filter (push) Successful in 2s
Sync to GitHub / sync (push) Failing after 2s
build-and-deploy / build (push) Failing after 27s
build-and-deploy / deploy (push) Has been skipped
sincronizar cambios
2025-05-30 02:13:01 -06:00

23 lines
870 B
JavaScript

import cron from 'node-cron';
import { syncEmpleadosToExternalDB } from './sync-empleados.js';
// Example cron job, runs every 5 seconds for demonstration/testing.
cron.schedule('*/5 * * * * *', () => {
const now = new Date();
if (!isNaN(now)) {
const formatted = now.toISOString(); // ✅ siempre funciona, sin locales
console.log('[cron]', formatted);
} else {
console.log('[cron] Fecha inválida');
}
});
// // Schedules the daily employee data synchronization to run at midnight.
// cron.schedule('0 0 * * *', () => {
// console.log('[CronWorker] Running daily employee synchronization task...');
// syncEmpleadosToExternalDB().catch(err => {
// console.error('[CronWorker] Error during scheduled employee synchronization:', err);
// });
// });
// console.log('[CronWorker] Daily employee synchronization task scheduled for 00:00.');