Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cron expression error and cron job not working as expected. #305

Closed
5achinJani opened this issue Nov 4, 2020 · 9 comments
Closed

cron expression error and cron job not working as expected. #305

5achinJani opened this issue Nov 4, 2020 · 9 comments

Comments

@5achinJani
Copy link

5achinJani commented Nov 4, 2020

According to the docs
image

First thing is the cron expression link that you've mentioned in the docs results in error with "Unexpected end of expression."
image

I used the same cron expression in the code:
image

And cron runs every second :
image

Here's the code for queue, worker and required things :

image

image

image

node version : v11.14.0

"bullmq": "^1.9.0",

Redis:
image

@5achinJani
Copy link
Author

This doesn't look cron expression or parser specific to me cause I even tried this :

export const registerPointsCronJob = async () => {
  await points_queue.add(
    points_jobs.POINTS_CRON_JOB,
    {
      params: {},
    },
    {
      repeat: {
        // cron: '15 3 * * *',
        every: 30000,
        limit: 10,
      },
    },
  )
  console.log('Points cron job registered')
}

And it keeps triggering every second and doesn't stop too.
image

I restarted my redis server and node server for both the cases just to make sure but it is still the same.

@manast
Copy link
Contributor

manast commented Nov 4, 2020

You need to delete the repeatable job in order to stop it, either that or do a "flushall" on redis.

@5achinJani
Copy link
Author

5achinJani commented Nov 5, 2020

Thank you for the response. So the better practice would be to get the repeatable jobs and remove them then register then cron jobs for every node server deployment or on local node server start/live-reload right?

Bull is smart enough not to add the same repeatable job if the repeat options are the same.

Though bull is smart enough to handle this but looking at a general case where we have a cron job and later down the line we need to update the cron expression we need to make sure to remove the repeatable jobs. It would be better to have this info in docs as it is not explicit enough. For anyone doing the initial testing or trying out this package to implement the cron job feature might hit this blocker and possibly think that this issue is with the bullmq package. just a suggestion. :)

@5achinJani
Copy link
Author

Also the cron expression part error "Unexpected end of expression." can also lead to confusion as it did for me so my suggestion would be to update the docs if you think the confusion concern that I raised is right.

cron expression error

cron expression error

@manast
Copy link
Contributor

manast commented Nov 5, 2020

Thank you for the response. So the better practice would be to get the repeatable jobs and remove them then register then cron jobs for every node server deployment or on local node server start/live-reload right?

Depends on your use case. Often you have some fixed set of cron jobs and then you do not need to do that.

@sbleon
Copy link
Contributor

sbleon commented Nov 5, 2020

@5achinJani, "15 3 * * *" is definitely a valid cron expression:
Screen Shot 2020-11-05 at 1 30 20 PM
See also: https://en.wikipedia.org/wiki/Cron

It look like the tool you're using is trying to evaluate the expression using as a "Quartz cron" expression, which is a non-standard format. (In my opinion, it's deeply irresponsible of Quartz to use the word "cron" when their formats are not interoperable.)

@5achinJani
Copy link
Author

@sbleon Thanks for the info :) I was following expression evaluator that bullmq has the link of it the docs : https://docs.bullmq.io/guide/jobs/repeatable

#305 (comment)

@sbleon
Copy link
Contributor

sbleon commented Nov 6, 2020

Oh, wow! It's pretty bad to have that link in the docs. That should definitely be changed.

@roggervalf
Copy link
Collaborator

Closing as the docs were changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants