Skip to main content

Capture stdout, stderr and exit codes from cron jobs and view them in a web UI

Project description

sioncronaich

sioncronaich - A lightweight cron-job monitoring tool written in Python - from Gaelic "to synchronise, to chronicle"

Python 3.12 Ruff pre-commit Coverage

sioncronaich wraps any shell command, captures its stdout, stderr and exit code, then POSTs the result to the sioncronaich web app, which stores everything in a local SQLite database and renders it in a simple web dashboard.


Quick start

1 — Start the web app

uv run uvicorn --factory sioncronaich.app:create_app --host 127.0.0.1 --port 8716

Pass --host, --port, and any other server options directly to uvicorn. See uvicorn --help for the full list.

The app reads the following environment variables:

Environment variable Default Purpose
SIONCRONAICH_DB ~/.local/share/sioncronaich/jobs.db SQLite database path
SIONCRONAICH_ROOT_PATH /sioncronaich ASGI root path when mounted behind a reverse proxy
LOG_CONFIG (unset — logs to stderr at INFO) Path to a YAML logging config file

2 — Wrap a command

sioncronaich --name "daily-backup" -- /usr/local/bin/backup.sh --full

The wrapper exits with the same exit code as the wrapped command, so existing cron alerting is unaffected. If posting to the web app fails, the error is printed to stderr but the exit code is still that of the wrapped job.

Usage: sioncronaich [OPTIONS] COMMAND...

Options:
  --name TEXT      Human-readable label for this job  [required]
  --endpoint TEXT  URL of the POST /jobs endpoint
                   [default: http://127.0.0.1:8716/jobs]
    --timeout INT    HTTP request timeout in seconds  [default: 10]

The endpoint can also be set via the SIONCRONAICH_ENDPOINT environment variable so you don't have to repeat it in every crontab entry. The --endpoint flag takes precedence if both are set.

export SIONCRONAICH_ENDPOINT=http://mon.example.com/sioncronaich/jobs

3 — Add to crontab

# m   h  dom mon dow  command
0     3  *   *   *    sioncronaich --name daily-backup -- /usr/local/bin/backup.sh
*/5   *  *   *   *    sioncronaich --name health-check -- /usr/local/bin/check.sh

4 — View the dashboard

Open http://127.0.0.1:8716 in a browser for a colour-coded table of recent job runs. stdout / stderr are available in collapsible panels.

The raw JSON API is also available:

Method Path Description
POST /jobs Ingest a new job result (used by sioncronaich)
GET /jobs List job results as JSON (newest first)
GET / HTML dashboard

Interactive API docs are served at http://127.0.0.1:8716/docs.


Reverse proxy with Caddy

sioncronaich is designed to be mounted at a sub-path behind a reverse proxy. The default sub-path is /sioncronaich; override it with SIONCRONAICH_ROOT_PATH.

example.com {
        reverse_proxy /sioncronaich/* 127.0.0.1:8716
        reverse_proxy /sioncronaich* 127.0.0.1:8716
}

Start the app with the matching root path:

SIONCRONAICH_ROOT_PATH=/sioncronaich \
  uv run uvicorn --factory sioncronaich.app:create_app --host 127.0.0.1 --port 8716

The dashboard is then available at https://example.com/sioncronaich and the ingest endpoint at https://example.com/sioncronaich/jobs.


Logging

By default the app logs to stderr at INFO level. To use a custom logging configuration, point LOG_CONFIG at a YAML file in the standard logging.config.dictConfig format. A ready-to-use example is provided at logging.yaml:

LOG_CONFIG=logging.yaml uv run uvicorn --factory sioncronaich.app:create_app

Development

uv sync --all-extras
uv run prek install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sioncronaich-0.3.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sioncronaich-0.3.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file sioncronaich-0.3.0.tar.gz.

File metadata

  • Download URL: sioncronaich-0.3.0.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sioncronaich-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ff8281610306a12479982167016d51310a37150676bdc40963675ee4de7c2382
MD5 33c443505b275b5a4614dd4bb85b149c
BLAKE2b-256 dbfe347e1a4ffebee414c0c7f92b5e63b3ffc4072a1513883fbd2d21ac2b7f23

See more details on using hashes here.

Provenance

The following attestation bundles were made for sioncronaich-0.3.0.tar.gz:

Publisher: python-publish.yml on ac3673/sioncronaich

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sioncronaich-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sioncronaich-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sioncronaich-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 994fdc43501cae35a7e475611f15fac24beeb7c3446db1b2f429b8128f17af5a
MD5 28ebee4ae85564db74a64c0e2de79a6d
BLAKE2b-256 38f3d2baa20ceeedb5a1d9946b32f80b530793cbed0e3179d6448b7a54b8d1fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for sioncronaich-0.3.0-py3-none-any.whl:

Publisher: python-publish.yml on ac3673/sioncronaich

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page