Package cron provides a pure-go mechanism for executing scheduled tasks with cron patterns. Cron patterns are a simple and flexible way to configure a schedule for which an automated task should run. Each component of the pattern can be: a single numerical value, a range, a comma-separated list of numerical values, an pattern, or a wildcard. Typically all values must match the current time for the job to run, however, when a day of month or day of week is specified (not a wildcard) those two values are OR-d. This can be confusing to understand, so know that the only real gotcha with this quirk is that there is no way to have a job run on a schedule such as 'every Friday the 13th'. It would instead run on every Friday and the 13th of each month. If the component is a numerical value, then the same component (minute, hour, month, etc...) of the current time must match the exact value for the component. If the component is a range, the current time value must fall between that range. If the component is a comma-separated list of numerical values, the current time must match any one of the values. Month and Day of Week values can also be the first three letters of the english name of that unit. For example, JAN for January or THU for Thursday. Components can also be an pattern for a mod operation, such as */5 or */2. Where if the remainder from the current times component and the pattern is zero, it matches. Lastly, components can be a wildcard *, which will match any value. Some example patterns are: This package conforms to the POSIX crontab standard, which can be found here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html Cron wakes up each minute to check for any jobs to run, then sleeps for the remainder of the minute. Under normal circumstances cron is accurate up-to 1 second. Each job's method is called in a unique goroutine and will recover from any panics. By default, Cron operates using the local timezone as determined by Golang, but this can be changed with the TZ field of a Tab object.
Package timespec provides functionality for parsing convenient definitions of points in time, such as "now next week". These definitions consist of three parts: a time, a date and an increment to add to the specified time. The date and increment part are optional, "now" can be used to indicate the current point in time. Times can be specified in hours (24-hour clock or wall clock), optionally followed by minutes. Additionally "noon" is recognized as an abbreviation for "12 pm" and "midnight" is an abbreviation for "12 am". The following are all valid times: "now", "1 am", "14:15", "1800". A date can either be a day of the week, such as "Tue" or "Tuesday", or a month name followed by a day number and optionally a year. The strings "today" and "tomorrow" are also recognized as dates, indicating the obvious. The following are all valid dates: "Feb 01", "today", "Mar 02, 2015", "tomorrow". Increments are useful for describing points in time relative to a reference time such as "now". An increment is either "+" or the word "next", followed by a number and a unit such as "month". The following are all valid increments: "+ 1 year", "next week", "+ 10 minutes". The syntax of timespec implemented by this package is the one understood by at(1) and reproduced here for convenience: The only valid timezone_name recognized by this implementation is "UTC" (matched case-insensitively).