every

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 11 Imported by: 0

README

every

Every translates english to crontab expression

every expression crontab expression
every 2 minutes */2 * * * *
every 2 minutes on Fri */2 * * * Fri
every day at 3 pm 0 15 * * *
every hour in Jun on Sun,Fri 0 * * Jun Sun,Fri

Everyfile config

every uses hashicorp hcl config structure.

every "2 minutes" {
  run = "command >/dev/null 2>&1"
  user = "ubuntu"
}

every "day at 3 pm" {
  run = "command >/dev/null 2>&1"
  user = "ubuntu"
}

every "hour in Jun on Sun,Fri" {
  run = "command >/dev/null 2>&1"
  user = "ubuntu"
}

TODO

  • every cmd to run commands
  • support Everyfile to generate crontab file (hcl)
  • read args to generate from input
  • run jobs as specific user
  • update crontab from config

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCrontab

func CleanCrontab(config *Config) error

CleanCrontab cleanup current Everyfile config fron crontab

func UpdateCrontab

func UpdateCrontab(crontab string, config *Config) (string, error)

UpdateCrontab returns updated crontab content

func WriteCrontab

func WriteCrontab(config *Config) error

WriteCrontab writes crontab

Types

type Config

type Config struct {
	Path    string
	Everies []*Every `hcl:"every,block"`
}

Config represents Everyfile config

func Parse

func Parse(name string) (*Config, error)

Parse reads config file

type Every

type Every struct {
	Every string `hcl:",label"`
	User  string `hcl:"user"`
	Run   string `hcl:"run"`
}

Every block data

func (*Every) CronExpr

func (e *Every) CronExpr() (string, error)

CronExpr parses every to crontab time expression

func (*Every) Cronjob

func (e *Every) Cronjob() (string, error)

Cronjob returns a crontab expression

Directories

Path Synopsis
cmd
every command

Jump to

Keyboard shortcuts

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