question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cron jobs stop working (Can an error inside the time function result in job stopping?)

See original GitHub issue

Description

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:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
albertosantinicommented, Oct 20, 2021

@franky-continu Try “1 */1 * * * *”. Zero second randomly seems problematic.

@Hexagon Thanks for the suggestion. I will give a try.

1reaction
Hexagoncommented, Oct 19, 2021

Try https://github.com/hexagon/croner, it has about the same interface, built to be solid, and is actively developed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cron job troubleshooting guide - Cronitor
Invalid permissions can cause your cron jobs to fail in at least 3 ways. This guide will cover them all. If your cron...
Read more >
Cron job mysteriously stopped running? - Stack Overflow
1. There should be something in your system log when the job was run. The other thing you could try is to add...
Read more >
Cancel a cron job that runs the script when there is an error in ...
If you script fails (with exit code = 1), your service will disable the timer and the script won't run again. Share.
Read more >
Why is my crontab not working, and how can I troubleshoot it?
Debugging cron commands · Check the mail! · Capture the output yourself · Look at the logs · Check that cron is running...
Read more >
Top Reasons Your Cron Job Isn't Running - Airplane.dev
Anyone who has used cron to schedule tasks in Linux knows that diagnosing and solving errors can be quite difficult. Cron jobs can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found