cron

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cron provides cron expression parsing, matching, and crontab file parsing for the memsh virtual shell scheduler, backed by robfig/cron/v3.

Index

Constants

View Source
const CronLogFile = "/.cron_log"

CronLogFile is the virtual-FS path where cron job output is appended.

View Source
const CrontabFile = "/.crontab"

CrontabFile is the virtual-FS path where the user's crontab is stored.

Variables

This section is empty.

Functions

func CronMatches

func CronMatches(sched CronExpr, t time.Time) bool

CronMatches reports whether sched fires at the given time (minute granularity).

robfig's Schedule.Next(t) returns the next fire time strictly after t, so we check whether the first fire time after (m − 1ns) is exactly m.

Types

type CronExpr

type CronExpr = robfig.Schedule

CronExpr is a parsed cron schedule. It is a type alias for robfig.Schedule so callers that already hold a CronExpr can pass it directly to CronMatches without any conversion.

func ParseCronExpr

func ParseCronExpr(s string) (CronExpr, error)

ParseCronExpr parses a cron expression string into a CronExpr (Schedule). Both 5-field ("m h dom mon dow") and @special forms are accepted. The day-of-week value 7 (Sunday alias used by many cron implementations) is normalised to 0 before passing to the parser, since robfig/cron/v3 only accepts 0–6 in that field.

type CronJob

type CronJob struct {
	Expr    CronExpr
	Command string
	Raw     string
}

CronJob is one entry parsed from a crontab file.

func ParseCrontab

func ParseCrontab(data string) ([]CronJob, error)

ParseCrontab parses the content of a crontab file into a slice of CronJobs. Blank lines and lines beginning with '#' are ignored. Each non-comment line must be either:

@special command...          (e.g. "@daily /backup.sh")
m h dom mon dow command...   (standard 5-field form)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL