cron job not working
When I set cron for every 5min , 30min, 24 hours like this it's working. But I when I set it at a particular time and a particular day (eg every Monday 2pm) it's not working.
13 Replies
Hi @Mrr. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, I can tell you that in a Discord support thread (https://discord.com/channels/686873244791210014/1215945587841831033), a community member suggested changing the cron schedule in the main.wasp file to run every minute and check that it’s pulling stats and saving to your database. It starts automatically when you run
wasp start
.
If you're still having trouble, I recommend checking out the Wasp community (https://discord.com/channels/686873244791210014) for more specific advice.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Mrr, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Where did you deploy your app? Does your server app maybe suspend if not active? (It can happen on Fly.io, check your server TOML file to see the options you have there)
Ok Thanks will check it. But in locally also when I schedule the time like in next 5 minutes. Cron is not running. When I set it every 5 minutes its running
Is there any alternative like bull mq or node cron you suggest??
Wasp curently supports
pg-boss
with our jobs. You can of course use a different queue directly, it's your project 🙂
when I schedule the time like in next 5 minutes. Cron is not running.Are you 100% sure the cron syntax is correct?
GitHub
pg-boss/docs/readme.md at master · timgit/pg-boss
Queueing jobs in Postgres from Node.js like a boss - timgit/pg-boss
job sendNewsletter {
executor: PgBoss,
perform: {
fn: import { generateWeeklyNewsletter } from "@src/weekly-newsletter/operations"
},
schedule: {
cron: "5 23 * * 2",
args: {=json { "useAlternateCase": true } json=}
},
entities: [User]
}
Wohooo @Mrr, you just became a Waspeteer level 3!
@miho when I specify time it's not running. Even locally also
Seems like you specified the job to task to run on every Tuesday at 11:05 PM.
Is that what you wanted? Can you try with a more common interval (e.g., every 2 minutes)?
Yes I was testing like when I do for every 2 minutes or 5 minutes..30min it works but when I specify a time it's not working. I waited for some time thought there can be delay like that but nothing happened
It's unlikely that certain time strings work while other's don't.
What's more likely is that it's some kind of timing issue/misunderstanding.
What I recommend making a regular cronjob using crontab (outside of Wasp) with the same string and seeing if that one executes like you expect. If not, debug it there. If yes, then come back here and we'll figure it out 🙂
Hey so when I tested it in deployment it works!! Only I when I tried it locally I am facing this issue.
Hmm, strange. I still recommend the same steps though.
Let me know how it goes.