Get-KFCronUtc
Syntax
Get-KFCronUtc
[-Pattern] <string> ("* * * * *")
[-Dt] <datetime> (System.DateTime.UtcNow)
[-ThrowErrors[:$true]]
Support
>= kenaflow 3.0.13
Return
Object of type kenaflow.CronDateTime.
Description
"Cron" is a job scheduling pattern known from Un*x and Linux.
With this command you can calculate the next valid date and time for a given start date (UTC) and a a CRON pattern.
The CRON syntax can be found here:
https://en.wikipedia.org/wiki/Cron
We will not describe the syntax here.
kenaflow supports:
- all match
*
("all") - single numbers
- lists, like
1,3,5,20,25,45
- ranges, like
1-30
- frequency, like
5/10
The return object of type kenaflow.CronDateTime looks like this:
public class CronDateTime
{
public DateTime Next();
public void Reset();
public DateTime Base {get;}
public DateTime Current {get;}
}
You can get such an object with Get-KFCronUtc
. Its based on a given System.DateTime and offers method Next()
to get the next valid DateTime matching the pattern.
When calling Next()
the new value is the basis for the next call to Next()
.
With Reset()
you can reset the sequence.
With Base
you get the initial DateTime
value.
With Current
you get the current DateTime
value from the initialization or the last call of Next()
.
Parameters
[-Pattern] <string> ("* * * * *")
The CRON pattern.
[-Dt] <datetime> (System.DateTime.NowUtc)
The DateTime as start reference.
[-ThrowErrors[:$true]]
This is a default parameter for all kenaflow cmdlets. If set to
$true
(default!) the engine will pass exception within the cmdlet to the script for further handling.
Example
Import-Module "C:\Program Files\kenaflow\kenaflow.runtime.dll"
$dt = [DateTime]::UtcNow.AddDays(10)
$cronDt = Get-KFCronUtc -Dt $dt -Pattern "5 6 * * *"
$cron.Next()