Google Cloud Scheduler trigger last day of month - google-cloud-platform

I want to create a trigger in Google Cloud Scheduler that runs at 9am on the 25th and the last day of each month (depending of the month that would be 28, 30, or 31th).
I assumed somethink like this might work, but GCP does not understand the L-syntax:
0 9 25,L * *
Any (elegant) ideas how to do it without having multiple triggers?

One trigger, with minimized overhead calls:
0 0 25,28-31 * *
Then, inside the function:
IF is25() OR islastDayOfMonthHelper()
work
ELSE
return

I just want to mention two alternative options I see for the end of month part of the question.
Simply run the function just past midnight to the 1st of each month. Depending on your use case this may be good enough.
Reschedule the function each month to the specific date which will be the last day of the next month.

Related

Cron Expression for AWS - First weekday after the 3rd of every month

I have been looking for an answer to the following from various searched but have yet to find one. I am looking to setup a cron for an AWS Step Function using the serverless framework. The cron expression I am trying to setup has the following criteria
It runs at 8am
It runs once a month
It only runs on a weekday
It runs on the 3rd or later in the month (if the 3rd falls on a Saturday or Sunday, it runs the following Monday as in bullet point 2 above)
Any help would be appreciated
I have tried searching but I am only finding expressions that solve my problem partially. I was looking at something like 0 8 3-31 * 1-5

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 SAM Parameter ScheduleExpression is not valid when adding day of week

I am making a CloudWatch event and I need it to run every Friday at 11pm UTC. I attempted to turn this on by doing cron(0 23 * * FRI *) which according to all documentation I could find, is perfectly correct syntax. However it was failing every time I tried to deploy it.
I found the issue was that if you set a day of the week specifically, then you can not set the third parameter to * it needs to be set to ?. This makes logic sense because the third parameter is Day of Month and so you can't have it run every day of the month AND every Friday. Updating to
cron(0 23 ? * FRI *) solved the problem for me.
An important and I suppose obvious note when setting cron values: Think about how each value affects the other values you've set. Does each one make logical sense in conjunction with the others?

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)

What is the difference between 'Interval' and 'Cron' triggers in APScheduler?

I am using APScheduler for my project. I went through APScheduler documentation. But I am not able to understand what is actual difference between 'Interval' and 'cron' triggers. Following definition was given in docs:
interval: use when you want to run the job at fixed intervals of time
cron: use when you want to run the job periodically at certain time(s) of day
With interval, you can specify that the job should run say every 15 minutes. A fixed amount of time between each run and that's it.
With cron, you can tell it to run on every second tuesday at 9am, or every day at noon, or on every 1st of January at 7pm. In cron, you define the minute, hour, day of month, month, day of week (eg. Monday) and year where it should run, and you can assign periodicity to any of those (ie. every Monday, or every fifth minute).
Anything you can achieve with interval can also be achieved with cron I think, but not the other way around.