Cron Expression - unique execution in a day

Hi Team,

I want to create a schedule in such a way that there are no duplicate executions on the same day.

The problem in creating a trigger for: “Every Monday & 1st of the month 12:15 AM”

Example cron expression (Non UiPath)-
15 0 * * * [[ $(date ‘+%a’) = “Mon” ]] || [[ $(date ‘+%d’) = “01” ]]

Cron Description - Run the job on the 1st of every month and all Mondays but if the 1st of the month is Monday then it should trigger only once.

Can someone guide me to create a trigger for this scenario

Thanks in Advance

@itsHM

Welcome to forums

May be it’s a work around you can schedule a cron expression to run the robot on every month as below

First Working Day of Every Month
0 0 0 1W*?*

Inside your workflow you can check as below

DateTime.Now.DayOfWeek.ToString = “Monday”

Then run your workflow else it will not run

Hope this help you

Thanks

1 Like

Thank You @Srini84

That makes sense but still, I would require 2 separate triggers right.

Can you think of anything in which I would require only 1 trigger for scheduling

  1. 1st of Month
  2. Every Monday

I tried 0 15 0 1 * 1 but Orchestrator is not accepting this expression.

Thanks,
Harsh Mehta

Hi @itsHM

Its not possible to achieve this with one Cron.

Unless you add logic like @Srini84 as suggested you would need to do something else.

You could do something like this.

Add two (2) Crons:
Cron 1:
Run every Monday at 12:15am using this Cron.
0 15 0 ? * MON *

Cron 2:
Run on Day 1 of every month at 12:15am.
0 15 0 1 * ? *
Then create a Non-Working Days Calendar for every Monday so it doesn’t run the same day as Cron 1.
See this post on how to make a Non Working Days calendar.

Hopefully this helps :blush:

Cheers

To add on to what has already been mentioned. UiPath Orchestrator uses the Quartz.NET framework, so you are limited by what this framework is capable of.

Where as your example above looks [to me] more like a Cron Expression with a [shell] command that is providing a logical OR that than should also have && to to run the intended command.

I recently had a similar [more] complex scenario than is currently capable where the scheduling requirement was to Run daily except for the last 2 business days of each month. So that means if Monday was the last business day of the month, it would not run Thu, Fri, Sat, Sun, Mon which is not in the capabilities of the current implementation.

The rule is simple enough that we could Tell it to run daily and than use non-working day calendar that has been forecasted out a couple years, but eventually we will need to review that calendar and it wouldn’t work for more complex scenarios (Know what Business days are, or managing exclusions at the hour/minute level and not just whole days).

It’s at a point that we are looking at implementing another module that can be included in the init of a project that would check an external source for a more flexible expression to determine if it should run or not. In addition to that an external coordinator / scheduler that can populate Non-working Day Calendars dynamically as well as more adhoc dynamic Triggers. Its a bit more overhead, but the currently the flexibility is not there unless you add the logic into your processes.

Unfortunately you need to have the Day of Month or Day of Week designation as a ? to be accepted by Orchestrator