#Cron job running every minute no matter what

11 messages · Page 1 of 1 (latest)

eternal oyster
#

Hey everyone! I have been working on a Medusa application and I've made a cron job to run a task that I want to run every night at midnight. I'm assuming I would follow the same cron expression shown in this example: https://docs.medusajs.com/advanced/backend/cron-jobs/create/ .

To test the job and the logic, I did have it set to run every minute by doing * * * * *. However, when I change it back to be 0 0 * * *, the job still runs every minute. Has anyone seen this before?

In this document, you’ll learn how to create a cron job in Medusa.

dreamy compass
#

This implements node-cron and it looks like the correct syntax is

┌────────────── second (optional)

│ ┌──────────── minute

│ │ ┌────────── hour

│ │ │ ┌──────── day of month

│ │ │ │ ┌────── month

│ │ │ │ │ ┌──── day of week

│ │ │ │ │ │

│ │ │ │ │ │

* * * * * *

#

Seconds seems to not be optional anymore. If I omit it, execution time is messed up

dreamy compass
#

Nah, it's not working as expected but this might be related to Bull.
Just tried 0 0 * * * *, this is supposed to run each hour at hour:00:00 but it still runs every minute

fickle jetty
#

@eternal oyster @dreamy compass o have the same issue, did you resolved ?

quartz ocean
#

I had the same issue and I honestly could not figure it out, some other were having the same issue. I posted here a couple times but no luck. I ended up creating an endpiont which runs the job, and then calling the endpoint using a "real" crontab from Linux.

dreamy compass
#

Hey fellas

#

Stop the backend from running, kill it and then log in to redis and flush all of its memory

#

Now run the backend again

quartz ocean