Skip to content

Run a queue every 3 months in a specified timezone? #855

Answered by Skn0tt
deadcoder0904 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Akshay! CronJob is meant for "static" cronjobs that are known at development-time. Things like "purge stale data from the database" or "send out some recurring email to customers".

If you want to dynamically schedule a cron job, you can do so using Queue's repeat.cron property.
Imagine you want to send out an end-of-week-summary to every user on your platform, but every user has their own time. Here's a snippet for that:

const user = {
  id: "abc",
  summarySchedule: "15_14_*_*_5", // every friday at 14:15, see: https://crontab.guru/#15_14_*_*_5
  timezone: "Asia/Kolkata",
  // ... potentially other user properties ...
}

await summaryQueue.enqueue(user.id, {
    id: user.id,
    repeat: 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by deadcoder0904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants