Run a queue every 3 months in a specified timezone? #855
-
First of all, thanks for Quirrel. It is really easy to use. I want to run a queue every 3 months in a specified timezone. I checked the API & I also checked Queue & saw it has a Basically, I want to send a queue every 3 months including right now in a specific timezone like Currently, my code looks like: await hello.enqueue(name, {
id: name,
delay: '30sec',
repeat: {
every: '10sec',
times: 2, // 2 * 10sec = 20sec
},
}) I have made a sample demo repo → https://github.com/deadcoder0904/quirrel-log Right now, with my code, it gave the scheduled date many hours later in the quirrel ui but executed it properly. I guess that's because of the timezone issue. Also, is there something like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi Akshay! If you want to dynamically schedule a cron job, you can do so using 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: {
cron: [ user.summarySchedule, timezone ],
}
}) Because this user is not known at development time, we can't define a async function unsubscribeUserFromSummary(userId: string) {
await summaryQueue.delete(userId)
} The |
Beta Was this translation helpful? Give feedback.
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
'srepeat.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: