A simple Cron library for go that can execute closures or functions at varying intervals, from once a second to once a year on a specific date and time. Primarily for web applications and long running daemons.

Cron.go

This is a simple library to handle scheduled tasks. Tasks can be run in a minimum delay of once a second--for which Cron isn't actually designed. Comparisons are fast and efficient and take place in a goroutine; matched jobs are also executed in goroutines.

For instance, you can use the following in your web application that uses MySQL:

func init() {
  cron.NewWeeklyJob(1, 23, 59, 59, func (time.Time) {
    _, err := conn.Query("OPTIMIZE TABLE mytable;")
    if(err != nil) { println(err) }
  })
}

License

Copyright 2011 Robert Kosek [email protected]. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY ROBERT KOSEK ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ROBERT KOSEK OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Robert Kosek.

Owner
Robert K
Zend Certified PHP Engineer, Web Programmer/Developer for @woodstreet Tinkerer, infrequent OSS contributor
Robert K
Similar Resources

K3ai Executor is the runner pod to execute the "one-click" pipelines

K3ai Executor is the runner pod to execute the

Welcome to K3ai Project K3ai is a lightweight tool to get an AI Infrastructure Stack up in minutes not days. NOTE on the K3ai origins Original K3ai Pr

Nov 11, 2021

Functional programming library for Go including a lazy list implementation and some of the most usual functions.

functional A functional programming library including a lazy list implementation and some of the most usual functions. import FP "github.com/tcard/fun

May 21, 2022

An easy to use, extensible health check library for Go applications.

Try browsing the code on Sourcegraph! Go Health Check An easy to use, extensible health check library for Go applications. Table of Contents Example M

Dec 30, 2022

Prometheus instrumentation library for Go applications

Prometheus Go client library This is the Go client library for Prometheus. It has two separate parts, one for instrumenting application code, and one

Jan 3, 2023

A simple wrapper to daemonize Go applications.

daemonigo A simple library to daemonize Go programming language applications. Installing $ go get github.com/tyranron/daemonigo After this command da

Jul 15, 2022

A simple package to daemonize Go applications.

A simple package to daemonize Go applications.

Nov 13, 2021

jacobin - A more than minimal JVM written in Go and capable of running Java 11 bytecode.

This overview gives the background on this project, including its aspirations and the features that it supports. The remaining pages discuss the basics of JVM operation and, where applicable, how Jacobin implements the various steps, noting any items that would be of particular interest to JVM cognoscenti.

Dec 29, 2022

Workaround for running ubuntu:21.10, fedora:35, and other glibc = 2.34 distros on Docker = 20.10.9

clone3-workaround: Workaround for running ubuntu:21.10, fedora:35, and other glibc = 2.34 distros on Docker = 20.10.9 Old container engines such as

Dec 1, 2022

The VM for running Back

Backvm The VM for running Back Back is a Concurrent Forth implementation, have fun Building the only dependency for backvm is the Go compiler Backvm d

Dec 11, 2021
Comments
  • Repo name does not work with Go get

    Repo name does not work with Go get

    Due to the repo's name ending with .go cron.go is not install-able with go get from Go 1.0.3.

    go get github.com/rk/cron.go
    stat github.com/rk/cron.go: no such file or directory
    
  • Why we don't use crontab style to describe task?

    Why we don't use crontab style to describe task?

    Hi rk,

    Go-cron is really a great and simple project.

    But I feel confuse about why we don't use crontab style to describe task?

    Like this:

    * */1 * * *  # we will run every hour
    

    With this, we can remove weekly job and monthly job.

vtysock is a vtysh replacement that directly sends commands to the vty sockets of the daemons

vtysock vtysock is a vtysh replacement that directly sends commands to the vty sockets of the daemons. By skipping the parsing and validation checks d

Dec 18, 2022
This package provides simple graph to execute functions in a group

Introduction This package provides simple graph to execute functions in a group.

Jul 22, 2022
🎄 My code for the Advent of Code of year 2021 in Go.

Advent of Code 2021 This repository contains all code that I wrote for the Advent of Code 2021. This year I chose to try and learn Go. Enjoy! Built wi

Dec 9, 2021
a cron library for go

cron Cron V3 has been released! To download the specific tagged release, run: go get github.com/robfig/cron/[email protected] Import it in your program as: im

Jan 1, 2023
GoLang - Produces a binary suitable for use in shell scripts and cron jobs for rotating IAM credentials.

AWS-Rotate-IAM-Key aws-rotate-iam-key makes it easy to rotate your IAM keys whether they be in your ~/.aws/credentials file or else where. This work i

Feb 9, 2022
Continuous profiling for long-term postmortem analysis

profefe, a continuous profiling system, collects profiling data from a fleet of running applications and provides API for querying profiling samples for postmortem performance analysis.

Dec 27, 2022
Get the long-term token for the Budget Insight API (sandbox)

token-budget-insight This small tool aims to automate the creation of the long-term token for a Budget Insight application; the process is explain in

Jan 7, 2022
This application is a tool that allows you to prepare mail designs specific to your group and make Christmas raffles.

What is this? This application is a tool that allows you to prepare mail designs specific to your group and make Christmas raffles. How is it working?

Dec 15, 2022
🏃‍♂️ A new way to execute commands and manipulate command output in Go

??‍♂️ A new way to execute commands and manipulate command output in Go

Nov 11, 2022
Go-fn Boilerplate for Web Functions

alya-go-fn-boilerplate Go-fn Boilerplate for Web Functions This projects aiming to create a deployment ready go skeleton webserver for fast developmen

Feb 5, 2022