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
Comments
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. I restarted my redis server and node server for both the cases just to make sure but it is still the same. |
You need to delete the repeatable job in order to stop it, either that or do a "flushall" on redis. |
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?
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. :) |
Depends on your use case. Often you have some fixed set of cron jobs and then you do not need to do that. |
@5achinJani, "15 3 * * *" is definitely a valid cron expression: 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.) |
@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 |
Oh, wow! It's pretty bad to have that link in the docs. That should definitely be changed. |
Closing as the docs were changed |
According to the docs
First thing is the cron expression link that you've mentioned in the docs results in error with "Unexpected end of expression."
I used the same cron expression in the code:
And cron runs every second :
Here's the code for queue, worker and required things :
node version : v11.14.0
Redis:
The text was updated successfully, but these errors were encountered: