Skip to content
This repository has been archived by the owner on Apr 19, 2020. It is now read-only.
/ gocron Public archive

Generates CRON expressions given an interval.

Notifications You must be signed in to change notification settings

jdav-dev/gocron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang CRON Expression Generator

Build Status

Takes a time.Duration and returns the closest CRON expression to fit that interval. Can also offset that CRON expression with by a second time.Duration. Returned expressions fit the standard/default CRON implementation.

Usage

Import:

import (
	"time"

	"github.com/jdav-dev/cron"
)

Every minute (minimum interval):

s, _ := gocron.IntervalToSchedule(time.Minute)
s.Expression()

returns * * * * *

Every 15 minutes:

s, _ := gocron.IntervalToSchedule(15 * time.Minute)
s.Expression()

returns 0,15,30,45 * * * *

Once a year (maximum interval):

s, _ := gocron.IntervalToSchedule(365 * 24 * time.Hour)
s.Expression()

returns 0 0 1 1 *

Every 15 minutes, offset by 5 minutes:

s, _ := gocron.OffsetIntervalToSchedule(15 * time.Minute, 5 * time.Minute)
s.Expression()

returns 5,20,35,50 * * * *

About

Generates CRON expressions given an interval.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published