Skip to Content
DocumentationGuidesAuto-update your instance with cron

Auto update with cron

You do not need cron to update the Hub stack. Companion Hub checks for a new release once a day and updates its own containers when Auto-update stack is enabled (the default). Use cron only to schedule cihub app update-all for your installed apps or to check for desktop app updates.

Companion Hub separates stack updates, installed app updates, and desktop app updates so unattended background updates never interrupt interactive desktop sessions or overwrite unpinned development builds. See Updating Companion Hub for the manual update steps for each installation method.

What updates itself

Hub has two parts that update separately:

PartUpdatesHow
Hub stack — the ci-hub container and its dashboardAutomatically, once a daySettings → System → Auto-update stack is on by default
Desktop app — the app and tray, and the bundled cihub CLIOnly when you start itSettings → System, cihub update, or your package manager

The stack update pulls the new Hub image and recreates only the ci-hub container. It leaves ci-hub-db (PostgreSQL), ci-hub-queue (RabbitMQ), and traefik running, and preserves your app data, state/settings.json, and installed apps.

Schedule installed app updates with cron

Hub never updates your installed apps automatically. On the Hub machine, cihub app update-all asks the running Hub backend to update every installed app that has a newer catalog version, taking a backup of each app before pulling the new image and recreating its containers.

Before scheduling cihub app update-all in cron, run it once manually in a terminal to confirm it succeeds:

cihub app update-all

Because cihub app update-all authenticates to the local Hub API using the device key stored under your Hub data root (<ROOT_FOLDER_HOST>) and reads .env.dev (or .env on Windows), schedule the cron job under the user account that runs Companion Hub rather than root:

# Run `crontab -e` as the Hub user to update all apps every Sunday at 04:00 0 4 * * 0 /usr/local/bin/cihub app update-all >> "$HOME/.local/share/companion-hub/logs/cron-app-update.log" 2>&1

You can also use cihub app start-all, cihub app stop-all, and cihub app restart-all for bulk lifecycle operations. See Update an installed app.

Which Hubs update themselves

Auto-update moves only a Hub that is pinned to a release image tag, such as ghcr.io/companionintelligence/ci-hub:0.3.0, and advances the pin in <ROOT_FOLDER_HOST>/.env.dev (or .env) to the newest stable release. It leaves every other Hub alone:

  • A Hub on a channel tag — :dev, :staging, or :latest
  • A Hub pinned to an @sha256: image digest
  • A Hub running a local build or an image from another registry

To move a Hub between channels on a CLI-managed install, change CI_HUB_IMAGE in the Hub env file and run cihub down && cihub up --detached.

Turn auto-update off

Use either of these methods:

  • In Settings → System, turn off Auto-update stack.
  • Set "autoUpdates": false in <ROOT_FOLDER_HOST>/state/settings.json. Use the JSON boolean false, not the string "false".

Hub reads state/settings.json on each daily check, so the change takes effect without restarting the Hub.

Check or install desktop app updates from a script

The desktop app requires user interaction to update. Two CLI commands help check or trigger updates from a terminal:

cihub update --check

Prints a CLI and Hub stack box comparing the cihub CLI version and the running Hub stack version, then queries the desktop app for available updates. It exits with status 1 when an update is available, and also exits 1 when the desktop app is not installed on the machine.

cihub update

Downloads and installs the new desktop app, then relaunches it. On Linux, the package upgrade prompts for administrator authorization, so it is not suited to an unattended cron job. On a headless machine without the desktop app, a standalone cihub binary falls back to cihub self-update, which requires GH_TOKEN or GITHUB_TOKEN in the environment and updates only the CLI binary. On a package-manager install, cihub update prints the upgrade command for your channel (such as brew upgrade --cask companion-hub or scoop update companion-hub) and exits with status 1.

Because the cihub CLI and the Hub stack update separately, a machine can run an older CLI while the stack auto-updates ahead. cihub doctor flags any version skew on its CLI vs stack line, and cihub version prints the CLI version followed by the running Hub build.

If an update fails

  • <ROOT_FOLDER_HOST>/logs/hub-stack-update.log records one block per stack update attempt, ending with result=ok or result=failed.
  • Settings → Logs (and <ROOT_FOLDER_HOST>/logs/app.log) records refused stack updates as Hub stack update refused: and skipped daily checks as Auto-update skipped:. Each daily stack update logs Auto-update: updating the Hub image only, from <old> to <new>.
Last updated on