django-q multple cron expression for a single job - django

Is there a way to use multiple cron expression for a single job in Django-Q.
I want a schedule a job for different day of different month.
want to combine this-
At 11:00 on day-of-month 10, 20, and 30 in January and every month from March through December--
0 11 10,20 1,2,4-12 *
At 11:00 on day-of-month 10, 20, and 28 in February.--
0 11 10,20,28 2 *

I don't think we can do that, a better approach will be to keep a single cron that runs on a daily basis and check is there any cron that needs to be run today(we may store the cron info in a database table).

Related

Cloud scheduler trigger on the first monday of each month

I'm trying to schedule a job to trigger on the first Monday of each month:
This is the cron expression I got: 0 5 1-7 * 1
(which ,as far as I can read unix cron expressions, triggers at 5:00 am on Monday if it happens to be in the first 7 days of the month)
However the job is triggered on what seems to be random days at 5:00 am. the job was triggered today on the 16 of Aug!
Am I reading the expression awfully wrong? BTW, I'm setting the timezone to be on AEST, if that makes difference.
You can use the legacy cron syntax to describe the schedule.
For your case, specify something like below:
"first monday of month 05:00"
Do explore the "Custom interval" tab in the provided link, to get better understanding on this.

AWS Cloudwatch event rule: Start and stop time

Is it possible to set start and stop time of cloudwatch event rules?
Use Case - I want to create a rule which triggers a lambda, but I want it to run at a specific date (every 2 minutes) and disable it at another date (these date interval can span across months).
As far as I know, when we create a rule (rate (2 minutes)), it starts running immediately. I can use this approach and in the lambda I can check if the current date is same as target date and proceed with lambda execution, and disable the rule when current date is greater than end date. Although, it might work but it does not seem the right approach since lambda would be unnecessarily executing until the target date.
Is there any way I can achieve the same thing without the hack?
Yes, you can set it to specific date only. For instance the following rule 0/2 0 28 9 ? 2020 would execute every 2 minutes on 28 Sep 2020 only:
Update
To span across months, I think you need separate rules. For example you could define two rules to span date range 28 Sep to finish 5 Oct: 0/2 0 28-31 9 ? 2020 and 0/2 0 1-5 10 ? 2020.

Configure a cron schedule for different intervals (hour and days)

Hello I am configuring jobs in GCP following the google cloud guide: https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules?&_ga=2.226390674.-907001748.1582817924#defining_the_job_schedule
I have to configure a job which will be executed once on weekdays at 6am and once on weekends at 5am. I am not pretty sure if it is possible to configure this for several intervals of time with something like an and statment:
0 5 * * 1-5 # monday to friday 5 am.
0 6 * * 6,0 # saturday and sunday 5 am.
In what way I can combine this intervals, besides that I need to add others ones but I am not pretty sure how can I do this.
Thanks.
You can't combine them in one record. The times do not match on any way. Of course if you have more jobs this eventually can be possible (depend on intervals)

Run Amazon CloudWatch Event every Sunday at 10:00 am UTC

I have already read Amazon CloudWatch Events - Schedule Expressions for Rules.
Now I want to trigger an event every Sunday at 10:00 am and I am confused if this is correct?
Currently I have cron(0 10 * * SUN *) & cron(0 10 ? * SUN *)
I don't know the difference between ? & * in Cronjob. So which one is correct is confusing?
Side Note
What is the difference between rate and schedule because rate is simpler to use so I can do like rate(7 days) but I don't know when it will run?
Will it run every 7 days from the moment of deployment?
That page says:
You can't specify the Day-of-month and Day-of-week fields in the same cron expression. If you specify a value (or a *) in one of the fields, you must use a ? (question mark) in the other.
It also says:
A rate expression starts when you create the scheduled event rule, and then runs on its defined schedule.
To run every Sunday at 10:00 AM UTC,
cron(0 10 ? * SUN *) or cron(0 10 ? * 1 *)
Use ? for Day-of-month part when Day-of-week has a value(here, SUN or 1) because when you want to run only on a specific day of the week, you can't use *, you can't say run everyday. Instead, we should say run one or another day of the month, using ?, which will be every Sunday of the month because we have set Day-of-week.
Refer Schedule Expressions for all details

CEP query based on date / time of the day

In WSO2 CEP, I made an execution plan that includes the following query:
(it will be fired if the temperature exeeds 20 degrees 3 times in a row within 10 seconds)
from MQTTstream[meta_temperature > 20]#window.time(10 sec)
select count(meta_temperature) as meta_temperature
having meta_temperature > 3
insert into out_temperatureAlarm
How can I achieve that the query is only applied if it is a special time of the day, e.g. 08:00 until 10:00 o'clock?
Is there something that I could put into the query like:
having meta_temperature > 3 and HOUR_OF_THE_DAY BETWEEN 8 and 10
You can use a cron window #window.cron instead of using a time window #window.time. You can specify Cron expression string for desired time periods in Siddhi [1]. Please refer quartz scheduler documentation to get more information on cron expression strings [2].
[1] https://docs.wso2.com/display/CEP400/Inbuilt+Windows#InbuiltWindows-croncron
[2] http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger