[![CI](https://github.com/flohoss/gocron/actions/workflows/ci.yaml/badge.svg)](https://github.com/flohoss/gocron/actions/workflows/ci.yaml) [![Coverage](https://raw.githubusercontent.com/wiki/flohoss/gocron/coverage.svg)](https://github.com/flohoss/gocron/wiki/coverage.html) [![RepoRanker](https://reporanker.com/badge/flohoss/gocron)](https://reporanker.com/repos/flohoss/gocron) A task scheduler built with Go and Vue.js that allows users to specify recurring jobs via a simple YAML configuration file. The scheduler reads job definitions, executes commands at specified times using cron expressions, and passes in environment variables for each job. Tagged GitHub releases include downloadable Linux binaries. Run `./gocron__linux_ --version` to inspect the embedded version metadata of a downloaded release binary. The server supports `--config /path/to/config.yaml` for a non-default configuration file.
## Table of Contents - [Table of Contents](#table-of-contents) - [Features](#features) - [How It Works](#how-it-works) - [Docker](#docker) - [run command](#run-command) - [compose file](#compose-file) - [Screenshots](#screenshots) - [Dark mode](#dark-mode) - [Light mode](#light-mode) - [API Docs](#api-docs) - [Configuration File](#configuration-file) - [YAML Configuration](#yaml-configuration) - [Software](#software) - [Star History](#star-history) - [License](#license) - [Development setup](#development-setup) - [Automatic rebuild and reload](#automatic-rebuild-and-reload) ## Features - Simple Configuration: Easily define jobs, cron schedules, and environment variables in a YAML config file. - Cron Scheduling: Supports cron expressions for precise scheduling. - Environment Variables: Define environment variables specific to each job. - Easy Job Management: Add and remove jobs quickly with simple configuration. - Pre-installed backup-software for an easy backup solution ## How It Works - Defaults Section: This section defines default values that are applied to all jobs. You can specify a default cron expression and environment variables to be inherited by each job. - Jobs Section: Here, you define multiple jobs. Each job can have its own cron expression, environment variables, and commands to execute. - Environment Variables: Define environment variables for each job to customize its runtime environment. - Commands: Each job can have multiple commands, which will be executed in sequence. ## Docker ### run command ```sh docker run -it --rm \ --name gocron \ --hostname gocron \ -p 8156:8156 \ -v ./config/:/app/config/ \ ghcr.io/flohoss/gocron:latest ``` ### compose file ```yml services: gocron: image: ghcr.io/flohoss/gocron:latest restart: always container_name: gocron hostname: gocron volumes: - ./config/:/app/config/ ports: - '8156:8156' ``` By default, gocron reads `./config/config.yaml`. You can optionally override the config file path with `--config /path/to/config.yaml`. SQLite data is stored in the same folder by default, and can be overridden with `db.location` inside the config file. Relative `db.location` values are resolved from the config file directory. You can also set the SQLite file name with `db.name` (default: `db.sqlite`). ### Environment overrides (`GC_`) Config values can be overridden via environment variables using the `GC_` prefix. - `GC_LOG_LEVEL=debug` overrides `log_level` - `GC_SERVER_PORT=9000` overrides `server.port` - `GC_HEALTHCHECK_TYPE=GET` overrides `healthcheck.type` Rule: dots become underscores and keys are uppercased (`server.address` -> `GC_SERVER_ADDRESS`). ## Screenshots ### Dark mode

### Light mode

### API Docs

## Configuration File ### YAML Configuration The entire configuration is managed via the YAML file, including settings for the timezone, logging, and server. For a complete and working configuration example, please refer to the [`config/config.yaml`](config/config.yaml) file in the repository. ### Software You can specify the software you want to install and the version you want to use directly in the configuration file. Available software packages include: apprise, borgbackup, docker, git, podman, rclone, rdiff-backup, restic, rsync, logrotate, sqlite3, and kopia. The version format depends on the installation method: - **apprise** (via pipx): version format like `1.2.0` - **docker** (via apt): version format like `5:24.0.5-1~debian.11~bullseye` - **Others** (via apt): standard apt version format Here is an example of how to set up specific software versions: ```yaml software: - name: 'apprise' version: '1.2.0' - name: 'borgbackup' version: '1.2.0' - name: 'docker' version: '5:24.0.5-1~debian.11~bullseye' - name: 'git' - name: 'podman' - name: 'rclone' - name: 'rdiff-backup' - name: 'restic' version: '0.14.0' - name: 'rsync' - name: 'logrotate' - name: 'sqlite3' - name: 'kopia' ``` ## Star History Star History Chart ## License This project is licensed under the MIT License - see the [LICENSE](https://github.com/flohoss/gocron/blob/main/LICENSE) file for details. ## Development setup ### Run tests ```bash # Run Go tests docker compose run --rm go test ./... # Install e2e dependencies docker compose run --rm yarn-e2e install --frozen-lockfile # Run e2e tests in Docker docker compose up -d docker compose --profile test run --rm e2e docker compose down ``` ### Update Dependencies ```bash # Node packages docker compose run --rm yarn install --frozen-lockfile docker compose run --rm yarn upgrade --latest # E2E packages docker compose run --rm yarn-e2e install --frozen-lockfile docker compose run --rm yarn-e2e upgrade --latest # Go packages docker compose run --rm go get -u ./... docker compose run --rm go mod tidy ``` ### Automatic rebuild and reload ```sh docker compose up ```