Hi ,
I am currently using django celery beat and cron scheduler for doing background scheduling. My current requirement is to generate an expression for running a task on last day of month — or to run a task thursday, x’th week every y months which translates to " 0 06 * */y 4#x
". but I was unable to find any resources which help me circumvent this issue. so please help me out.
Thanks
What is “this issue” that you need help with?
Is this expression that you’ve written not working? Is it throwing an error message?
hi, Thanks for the reply.
Let me elaborate on this issue I am facing. the cron expression evaluates correctly when i check if expression is correct if i use external websites to evaluate the expression. but when I use do the same and update the cron expression to djangocelerybeat.models.CrontabScheduler , it wont schedule correctly and misses the time. This unexpected behavior makes me doubt if i am writing expression correctly or if django celery beat doesn’t support these flags/operators. if what i mentioned is confusing
Please write an cron schedule expression which executes on “last Thursday every 2 months”.
I wrote it as “0 00 * */2 4#L”.
Thanks for your time.
No, it doesn’t appear as if the CrontabScheduler permits the “#L” expression.
Right off-hand, I can only think of a couple ways to handle this.
But I don’t think the Beat scheduler is going to do that for you.
(You could also create a new scheduler that more closely follows the cron conventions, but I’m guessing you don’t want to go that far.)
First of all Thank you for your time. about solutions – If i am reading what you meant correctly , You are suggesting having a part of schedule at schedule level and a part of it in code level — if this entire thing doesn’t work then I just have to start creating a new scheduler class which might be hard to implement and prone to errors. Am I right?
If I am adding a part of it to code and part to schedule , then how can I keep tab of which schedule needs what extra features from code? Just asking because I am very inexperienced with such things.
If I cant do the first way of doing things, Then how can I implement a scheduler that meets my needs? a little bit of digging around helped me find that I have to use BaseScheduler class from django celery beat, but nothing beyond that. I might need to implement few Model methods but How do we test them if we have to do that? what more is what kind of issues do i have to look out for? (again, I am asking this because I am newbie to this and am learning. I will look around for this but any resource you might point out to will be very much appreciated).