Specifying periodic time intervals (eg: operating hours of an office) - time

I am designing an API where I need to specify the operating hours of an office. It could be like
0815-1745 every Monday to Friday
Every Second Saturday
On expected rush days till 2000 [eg: 2021-06-15 1745-2000]
Each interval will be specified separately and the final operating hours will be the sum of all the individual intervals.
I need a means to specify this succinctly. There are two existing choices I am aware of:
Extended cron format as defined in https://crontab.guru/
Asterisk GotoIfTime syntax: https://www.voip-info.org/asterisk-cmd-gotoiftime
The cron syntax is not really able to defined ranges like 0815-1745 every Monday to Friday, but the Asterisk syntax is quite capable.
Does any other [better?] syntax/means exists which can achieve the same result? A library to do so will be mighty cool.

Related

Power Automate to schedule the flow after first week of the month on a certain weekday

I have a simple thing to do. I have a recurrence flow that refreshes my dataset and then the report goes out based on that.
now my issue that I need to run the flow only on TUESDAYs except the first Tuesday of the month.
I have set up a trigger condition on the above as below but it's not working. It should have run today but did not.
#greater(int(utcNow('dd')),7)
What I suspect is that timezone difference. because my original Recurrence is using +10 timezone but the conditions says utcNow() , maybe it's reading from there and 11am has still not arrived in that timezone. but I need it to run in +10AEST timezone.
Found an answer for it in case anyone else needs it.
The above expression is correct, except that I needed to use #greaterOrEquals(int(utcNow('dd')),7)
not sure why! but it just works...

Task scheduler to run tasks only during the last full workweek of the month

I have multiple tasks that need to be scheduled during the last full workweek (Monday through Friday) of every month. These will be scheduled from a Windows Server 2016 server. I cannot figure out the logic to do it.
Additional info to help:
July 2020 is a perfect month to just say run on the last Monday/Tuesday/etc. Most months will not end with a full workweek though. It may end on a Tuesday and the full workweek ended 4 days before that.
I have ideas of how to do this, but they are not fully formulated:
Find the last Friday of the month and start 4 days before that.
Find the last Monday with at least 4 additional days in the month after.
If the last day of the month is Sunday, start 6 days before that; Saturday, start 5 days before that; etc.
What is the cleanest method to do this in task scheduler? (The scripts being scheduled are in PowerShell, though I don’t think that matters).
So, your situation is: "I have a script, I have a complicated date schedule, and I would like my script to be launched according to that schedule.",
and your question is: "How to perform this scheduling in Windows task scheduler?"
My answer would be:
Don't do it like that, but write a new script which verifies the current date, and verifies if the current date corresponds to the complicate date schedule (in that case, launch your original script), and use Windows task scheduler to launch this new script on a daily basis.
As for making that new script, this URL explains how to perform date handling in Powershell.
This particular use case can actually be done fully in the Task Scheduler.
When adding a new trigger, select Monthly then for Months select <Select all months>. Then, change the radio button below it to Onand chooseLastand`.
May I suggest a solution:
In VBA write a very short Sub routine indicating the current date (using "Now() + 1".
Then use "instr(1,string1,""/"")" to see whether the second entry in the resulting date (such as "5/1/2022") is a "1". If it is, then you can issue a warning on a prepared Notepad.txt the day before the 1st of the month that also provides an answer to your question regarding scheduling an event on the 1st of every month. The routine is to run (in the background) every day until it reaches this particular occurrence.

Use gocron scheduler to schedule job on specific day at specific time

I want to schedule a job on a specific day at a specific time with some interval. I am using gocron scheduler for this. But I can't find a way to start a job on specific day. e.g. I want to execute a job on 7 Sept 2019 at 330pm. From 7 Sept, I want that job to be executed daily or weekly. How can I do that using gocron. or Any other packages available?
I tried passing UTC time to gocron.At() but its panics as it's expecting only "03:30" time formats and doesn't expect date.
When looking at the documentation for gocron, it does not seem to be designed to support scheduling things for specific days. It seems to be designed as a way to schedule things to run at various intervals, very similar to what the original cron utility was designed to do. So you would specify "I want this function to get called every 2 hours" or "I want this function to get called every Sunday at 3PM". There does not seem to be any documentation about starting jobs from a specific day.
The mentioned At(string) method is documented as allowing you to specify a time of day to run something. So you would use that to set that your job runs at 3:30PM.
If you wish to specify a start time, you would likely need to find another scheduling library or implement it yourself by creating a goroutine that sleeps until a specific time. The StackOverflow post mentioned by domcyrus looks like an excellent resource for implementing it yourself as well as listing some other scheduling libraries.

How to run a job on specific times every day from Monday to Friday in Rundeck?

Is there any way to run the job every day from Monday to Friday at 45 mins time interval from 2.45 pm to 5 pm. (The job should run at 2.45pm , 3.30pm, 4.15, 5.00). Please help.
Thank you.
I know of two ways:
One way is to create four jobs scheduled at a single time every Mon-Fri. Give each a single step, which is a job reference to the real job. For example, the first job would be scheduled to run at 2.45pm every Mon-Fri, the second at 3.30pm, etc. You're not making copies of the existing job, just single-step jobs that reference the original.
That approach lets you manage each scheduled time individually.
Another way is to schedule it every 15 minutes from 2.00pm to 5.45pm, and add an initial step that fails if the time is before 2.45pm or after 5.01pm. If you don't want to see these failures, you could add an error step to that first step which marks the job succeeded even if it's really skipping all the real steps.
Paul M. Lambert
Platform Solutions Architect
Rundeck, Inc.

Crontab on week numbers

I would like to set a cronjob on certain week numbers. The reason for that, I have a script that should run once a day except of week number 8 and 9. There it should run twice a day.
How can I set a cronjob based on week numbers?
Cron doesn't offer that level of scheduling flexibility, so you have to make your script smarter.
Make your cron job run twice a day, leaving some log file or other artifact that shows it has run. Then have it check whether it's already run that day, and finally also check the week number to see if it's OK for it to run the second time.

Resources