Cron jobs stop working (Can an error inside the time function result in job stopping?)
See original GitHub issueDescription
Guys for some time now, about 3 weeks we have been experiencing cron job stopping. We can’t identify and there is talks to move away from this library.
I’m sure this is an easy thing, this library has been the most robust one ever.
I coded our scheduler with it and it served us for 6 years. I’m not in the issue right now, but I want to collaborate.
We have a package declaration of 1.6.0 ("cron": "^1.6.0",
).
We user an every minute one that stops calling our notifications processing. (or so we think).
Almost all or our jobs are the same (they just change in the rest resource being called)
function schedule() {
cronJob = cron.job("0 */1 * * * *", async function() {
log.info('Scheduled Job ' + name + ' called');
const api_resource = process.env.API_BASE_URL + 'v3/notifications/process';
const now = new Date();
const opts = {
headers: {'Authorization': 'TOKEN'}
};
try {
await axios.post(api_resource, {}, opts);
log.info('Scheduled Job ' + name + ' triggered successfully.');
} catch (error) {
log.error('Scheduled Job ' + name + ' was not posted. Error was', error);
}
});
cronJob.start();
}
We dir list all jobs, and for each we call the function schedule.
I understand the lack of items but any pointers, any ideas would be appreciated it. Thank you so much.
The bottom line is that every so often we need to redeploy our api to restart our scheduler.
Screenshots
No response
Additional information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top GitHub Comments
@franky-continu Try “1 */1 * * * *”. Zero second randomly seems problematic.
@Hexagon Thanks for the suggestion. I will give a try.
Try https://github.com/hexagon/croner, it has about the same interface, built to be solid, and is actively developed.