Hi all,
I need a cron expression to schedule a trigger every two Fridays.
I have tried this one “0 0 * * Fri [ $(expr $(date +%W) % 2) -eq 1 ] && /path/to/command”, but I am getting Invalid cron expression.
Could you help me, please?
Thanks.
Hi all,
I need a cron expression to schedule a trigger every two Fridays.
I have tried this one “0 0 * * Fri [ $(expr $(date +%W) % 2) -eq 1 ] && /path/to/command”, but I am getting Invalid cron expression.
Could you help me, please?
Thanks.
"0 0 * * Fri#1,Fri#3"
This expression will schedule the trigger to run at midnight (0:00) on the first and third Fridays of each month. You can adjust the numbers after the #
to select different occurrences within a month.
0 0 * * 5 [ $(expr $(date +\%W) \% 2) -eq 1 ] && /path/to/command
In this expression:
0 0
specifies midnight as the time of day.* *
allows the command to run every day and every month.5
represents Friday as the day of the week (Sunday is 0, Monday is 1, and so on).[ $(expr $(date +\%W) \% 2) -eq 1 ]
is your condition for running the command every two Fridays.Hope it helps!!
Try this:
0 0 * * 5 [ $((($(date +\%U) \% 2)) -eq 1 ] && your_command_here
0 0 * * 5 schedules the task to run every Friday at midnight.
[ $((($(date +%U) % 2)) -eq 1 ] is to run the command only if the current week number is odd
we assume the cron is intended to be used it within Orchestrator trigger configuration, right?
A month can also have more then 4 weeks
so a static first, third friday will not match
A biweekly interval is in general against the nature of cron
Working with a dynamic part within the cron is not supported when specifying the cron for ORC trigger setting
Working with a dynamic part within the cron
in other words: $(date… will not work / be accepted
Yes, you all right. It’s an orchestrator trigger.
If you want to trigger the bot for second and forth Friday of a month, use the below expression
Cron Expression:
0 0 * * 5#2,5#4
Hope it helps!!
You cannot directly do this only using orchestrator
You have to use a logic in your code as well to run as expected
One thing you can do is …
Hope this helps
Cheers
That’s work great. Thanks a lot for your response.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.