Skip to main content

Cron-style scheduler service for runspec runnables installed in one venv

Project description

runspec-scheduler

Cron, but limited to runspec runnables installed in one venv.

A long-running per-venv scheduler daemon (systemctl --user) that runs runnables installed in its own venv on a cron/interval cadence — independent of any desktop console. It is itself a runspec runnable, so runspec-console can detect it and manage its schedules over SSH, but discoverable = false keeps it out of the Forms tab / runspec serve MCP surface.

Why

A console-driven schedule only fires while the desktop console is open, and it's per-operator. runspec-scheduler gives you shared, always-on schedules that live on the host and run whether or not a console is connected.

Install

# Into the same venv whose runnables you want to schedule:
pip install runspec-scheduler

# Install + enable the systemd --user service for this venv (as yourself):
runspec-scheduler install-service
loginctl enable-linger "$USER"     # survive logout

install-service writes ~/.config/systemd/user/runspec-scheduler-<venv>.service (one daemon per venv) and runs systemctl --user enable --now. To do it by hand, see deploy/runspec-scheduler.service.

Running the daemon as a service account

systemctl --user needs the account's own user session (XDG_RUNTIME_DIR + D-Bus). A bare sudo -u <acct> doesn't set that up, so systemctl fails with "Failed to connect to bus: No medium found." Run from a login shell and enable lingering:

sudo loginctl enable-linger serviceacc              # persistent user systemd, survives logout
sudo -iu serviceacc runspec-scheduler install-service   # -i = login shell (sets up the session)
sudo -iu serviceacc systemctl --user status runspec-scheduler-<venv>

The -i (login shell) is what wires up XDG_RUNTIME_DIR, D-Bus, and HOME for the account. If lingering is already on, install-service also recovers XDG_RUNTIME_DIR from /run/user/<uid> on its own; otherwise it returns a hint with the exact commands above (the unit file is written either way, so you can finish with a manual systemctl --user enable --now).

Use

runspec-scheduler add --id nightly --runnable backup --cron '0 2 * * *'
runspec-scheduler add --id poll   --runnable healthcheck --every 15m --args '{"level":"warn"}'
runspec-scheduler list
runspec-scheduler run-now --id poll
runspec-scheduler remove --id poll
  • Exactly one of --cron (5-field cron) or --every (15m / 1h / 1d).
  • --args is a JSON object passed to the target runnable.
  • Adding/removing a schedule hot-reloads the running daemon (mtime poll, ≤ 5s).

Config

Schedules live in {venv}/runspec_scheduler.toml (override with --config or $RUNSPEC_SCHEDULER_CONFIG). The daemon keeps a rotating audit log at {venv}/logs/scheduler.log; live logs via journalctl --user -u runspec-scheduler-<venv> -f.

Credentials (run_as runnables)

runspec-console can attach service-account credentials to a remote schedule. For a runnable that declares run_as, the selected credentials are written to a 600 env file owned by the run_as account in that account's home; the daemon points RUNSPEC_ENV_FILE at it and escalates to run_as when firing. Credentials are never placed on a command line. This requires the daemon/SSH user to have passwordless sudo -u <run_as> (the same precondition as running that run_as runnable at all).

Runnables without run_as run as the daemon's own user with the daemon's environment (systemd EnvironmentFile) — no console credential injection.

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

runspec_scheduler-0.1.1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

runspec_scheduler-0.1.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file runspec_scheduler-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for runspec_scheduler-0.1.1.tar.gz
Algorithm Hash digest
SHA256 34670bda608d91ca27c736e126bd75acd5b6468097cf53efcc87a5420062c36c
MD5 d315d5cfd23d413a486775ecba299388
BLAKE2b-256 8be1adc3a863dbae7dc2d5fcf625139ae0cc64411d2989e6b4903f3bc3e6cf34

See more details on using hashes here.

Provenance

The following attestation bundles were made for runspec_scheduler-0.1.1.tar.gz:

Publisher: scheduler-release.yml on JasonFinestone/runspec

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

File details

Details for the file runspec_scheduler-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for runspec_scheduler-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a122caec8e443780ef4715bf595f091dc48385d25cdb90f48eff5ab16565606c
MD5 1184550f966abf1c6f4f7db04f404ba8
BLAKE2b-256 04bae5d70bd8bcf63ea29584a93c53afb01ff960f2c125c7da1a0262ffb00ba1

See more details on using hashes here.

Provenance

The following attestation bundles were made for runspec_scheduler-0.1.1-py3-none-any.whl:

Publisher: scheduler-release.yml on JasonFinestone/runspec

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