Skip to content

Command line: autominer

autominer is the command that runs the AutoMiner server and looks after its configuration. Day to day you use the web UI; the command is for starting the server, checking what is configured, storing API keys, and a few upkeep and repair jobs.

This page lists every subcommand, its options and defaults, an example, and whether it changes your data. For where settings live and how they are resolved, see Configuration.

Linux and macOS. install.sh puts autominer on your PATH. If a shell answers autominer: command not found, run the copy inside the checkout once to link it:

Terminal window
<checkout>/core/.venv/bin/autominer install-command

Run commands as the same user as the service, so they read the same data directory:

How the service was installed Data directory (AUTOMINER_HOME) Run commands as
install.sh as root (systemd system unit) /var/lib/autominer root (sudo autominer ...)
install.sh as a normal user (systemd user unit, or launchd on macOS) ~/.local/share/autominer (or $XDG_DATA_HOME/autominer) that user

If you use another directory, set AUTOMINER_HOME for the command too.

Windows (the installer). The installer does not put autominer on PATH, and only the Start-menu launcher sets the data directory. Set it yourself, then run the command through the bundled Python. In PowerShell:

Terminal window
$env:AUTOMINER_HOME = "$env:LOCALAPPDATA\AutoMiner\data"
& "$env:LOCALAPPDATA\Programs\AutoMiner\python\python.exe" -m autominer.cli doctor

Replace doctor with any command on this page. Without AUTOMINER_HOME, the command looks in a different, empty data directory.

Finding help from the command itself:

Terminal window
autominer # the overview: first-run steps and help topics
autominer --help # every command
autominer doctor --help # one command's options
autominer help ANKICONNECT_URL
Command What it does Changes data?
serve Runs the server: web UI, API, job worker, trackers Yes
doctor Shows which features are configured, and where each setting comes from No
setup Asks feature by feature and writes the installation .env and secrets Yes (.env, secrets)
help Explains a topic, a feature or one setting No
install-command Links autominer into a PATH directory Only the link
config check Same as doctor No
config template Prints a template .env No
config set Writes one non-secret setting into the .env Yes (.env)
secret set / unset / list Stores, removes or lists API keys set/unset: yes
spotify authorize Gets and stores a Spotify refresh token Yes (one secret)
judge fetch Downloads the local judge (1.1 to 2.7 GB) Yes (files)
retention-sweep Lists, or deletes, source videos that are done with With --commit
session-sweep Closes watch sessions that never ended With --commit
qa-purge Deletes sources recorded in QA mode With --commit
db-init Creates the database schema Yes
recompute-intervals Rebuilds watch time from the raw events Yes
wordkey-scan, wordkey-repair, target-scan Find, and repair, old mis-keyed cards wordkey-repair --commit only
maintenance Pauses new work for an upgrade, and resumes it Yes (the pause state)
release-gate, verify-deployed Deployment checks for a managed server No
producers Which clients may post watches, and the admission policy approve, revoke, policy --set
stremio-replay-dry-run Diagnoses parked Stremio watches from a copy of the tracker state No (may refresh a cache file)
stremio-adapter, spotify-adapter Retired; print a note and exit No

Usage errors (an unknown command or a missing argument) exit with code 2.

Runs the server: the web UI and API, the job worker that runs every stage, and the Stremio and Spotify trackers when those platforms are installed and have their credentials.

Option Default Meaning
--host 0.0.0.0 Address to listen on. 0.0.0.0 answers on every network interface.
--port 8801 Port to listen on.
Terminal window
autominer serve --host 0.0.0.0 --port 8801

Changes data: yes. The first start creates the database. Every start adds new columns to an existing database, and the worker starts running queued jobs once the start-up passes finish.

What to know:

  • install.sh already runs serve as a service, so you rarely type it. Use it to run the server in a terminal while you look at its output (stop the service first, or pick another port).
  • A database last started before commit 7f134861 is refused at start-up, with a line that begins [startup] REFUSED:. See Troubleshooting.
  • Press Ctrl+C to stop it. A job that is still running is given 30 seconds and then abandoned; it shows as failed after the next start.
  • When AUTOMINER_CORE_URL is not set, serve sets it, for its trackers, to the address it listens on (http://127.0.0.1:<port> for 0.0.0.0).

Prints one row per feature (Anki, Yomitan, each API key, backup, ffmpeg…) with its state, and for each setting where its live value comes from. It never prints a setting’s value, masked or otherwise; the only path it shows is the data directory’s.

Option Default Meaning
--online off Also makes one cheap read-only request per configured provider (network).
--json off Prints the report as JSON.
--env-file PATH none Also considers an installation .env you have not rendered yet. A missing file exits 2.
--rendered-dir DIR $AUTOMINER_HOME/env Where the rendered service environment files are.
--verbose off Also lists optional settings that are at their default or unset.
Terminal window
autominer doctor
autominer doctor --online

Changes data: no. It also asks the running server (at AUTOMINER_CORE_URL, http://127.0.0.1:8801 by default) which trackers are running.

Each feature is in one of three states:

State Meaning
configured It has what it needs.
not configured It is off because nothing was set. This is not an error.
misconfigured Something is set but wrong: a partial set (for example two of the three Spotify credentials), an unreadable key file, a bad URL or number, or a data location this user cannot write.

The source of a setting is one of env, env/<service>.env, .env (render to apply), secrets file, file (NAME_FILE), settings row (saved in the web UI), default or unset.

A shortened example:

AUTOMINER_HOME: /var/lib/autominer (default)
Core ledger + web UI configured
- sources: this box
Stremio watch tracking not configured
STREMIO_AUTH_KEY unset (required, secret)
Anki export (AnkiConnect) configured
ANKICONNECT_URL settings row (required)
ffmpeg / ffprobe configured
- ffmpeg and ffprobe found on PATH
Trackers in the AutoMiner at http://127.0.0.1:8801: none running

With --online, a configured feature’s row adds online: ok, auth failed, unreachable, error or skipped. Spotify is always skipped, because refreshing its token could change it.

Exit codes:

Code Meaning
0 Every configured feature is healthy. Features that are not configured do not count.
1 A feature is misconfigured, or failed its --online check (auth failed, unreachable or error).
2 Usage error.

The web UI shows the same table under Settings › Overview › Setup state.

First-run configuration in the terminal. For each optional feature it asks Enable <feature>? [y/N] ([Y/n] when it is already configured), then asks only for the settings that feature needs. It checks every answer (URLs, numbers, characters in a key) and allows three tries. Keys are typed without being shown.

Option Default Meaning
--env PATH the .env at the root of the checkout The installation .env to write. Required when the command does not run from a checkout (for example on Windows).
--non-interactive off Reads KEY=value lines from standard input instead of asking. Blank values are skipped.
Terminal window
autominer setup
autominer setup --non-interactive < answers.env

Changes data: yes. Plain settings go into the installation .env (created with mode 0600 from the template if it is missing; in an existing file only the chosen keys change). Keys go into the secrets directory, one file each. It never restarts anything.

At the end it prints the feature table, offers Run the read-only online checks now? [y/N], and prints the next steps. The exit code is the same as doctor’s; a usage problem exits 2.

Many people never need setup: the setup page that opens on a fresh install, and Settings › Services, store the addresses and API keys most installs use.

The .env and your service. A value written into the .env reaches the server only once it is rendered into $AUTOMINER_HOME/env/ with scripts/operations/configure_env.py and the service reads that file. The Raspberry Pi service unit (deploy/autominer.service) reads it. The service that install.sh creates reads no environment file, so add the setting to the unit yourself (for example with systemctl edit autominer). Keys stored with autominer secret set, setup or the web UI need none of this: the server reads them from the secrets directory each time it uses them.

Explains configuration from the settings registry: what a setting is and how to set it. It never prints a value.

Argument Meaning
TOPIC (optional) config, settings, secrets, install, services; a feature key such as anki, yomitan, spotify, backup, stremio or subtitles; or a setting name such as ANKICONNECT_URL (any case). Blank: the overview.
--all With settings, also lists advanced settings.
Terminal window
autominer help settings --all
autominer help anki
autominer help OPENAI_API_KEY

Changes data: no. An unknown topic exits 2 and suggests the closest names.

help config, help services, and the help for a feature or a setting print restart commands for the Raspberry Pi deployment (/opt/AutoMiner/deploy/safe-restart.sh). On another install, restart the service the way you installed it (see Logs and restarts).

Links the autominer of the Python environment that runs it into a directory on your PATH.

Option Default Meaning
--bin-dir DIR /usr/local/bin as root, ~/.local/bin otherwise Where to put the link.
--force off Replaces whatever is at that path. Without it, anything that is not an AutoMiner launcher is left alone and the command exits 1.
--dry-run off Says what it would do and changes nothing.
Terminal window
core/.venv/bin/autominer install-command
core/.venv/bin/autominer install-command --bin-dir ~/bin --dry-run

Changes data: only the link. It edits no shell profile. If the directory is not on your PATH, it prints the line to add. It warns when a different autominer comes earlier on PATH. If you move the checkout, run it again from the new place. Exit code 0 on success, 1 when it refuses or cannot write.

Subcommand What it does Changes data?
config check Exactly doctor, with the same options. No
config template Prints the template installation .env (the same text as .env.example: every non-secret setting by feature, and the names of the secrets that do not belong in it) to standard output. No
config set NAME VALUE [--env PATH] Writes one non-secret setting into the installation .env, creating the file if needed. Yes
Terminal window
autominer config set ANKICONNECT_URL http://<anki-computer>:8765
autominer config template > my.env

config set refuses a key (NAME is a secret; use autominer secret set NAME instead), an unknown name, and a setting that is not read from the .env, each with exit code 2. Without --env it writes the .env at the root of the checkout; outside a checkout pass --env. See the note under setup about the .env reaching your service.

API keys and other credentials are stored one file each, mode 0600, in the secrets directory ($AUTOMINER_SECRETS_DIR, by default $AUTOMINER_HOME/secrets, mode 0700). No command prints a stored value.

Subcommand What it does Changes data?
secret set NAME [--env PATH] Stores NAME. The value comes from a hidden prompt, or from one line of standard input. Never put it on the command line. Yes
secret unset NAME [--env PATH] Removes the stored file. Yes
secret list [--env PATH] Every known secret: set, unset or unreadable, and its source. No

--env names the installation .env to read the data paths from.

Terminal window
autominer secret set OPENAI_API_KEY
autominer secret set JIMAKU_API_KEY < jimaku-key.txt
autominer secret list
autominer secret unset JIMAKU_API_KEY

What to know:

  • A stored key takes effect immediately: set prints no restart needed. Spotify’s three credentials are the exception: set prints restart AutoMiner to use it.
  • A value set in the environment, or still in the .env, wins over the stored file. set and unset say so by name.
  • unset exits 1 and says NAME is STILL SET via <source> when another source still provides the value. Remove it there.
  • An unknown name exits 2 (NAME is not a registered secret).
  • autominer help settings --all lists every secret name. Settings › Services › API keys in the web UI stores many of the same keys, into the same files.

Gets a Spotify refresh token that may read your playback, and stores it as SPOTIFY_REFRESH_TOKEN.

Option Default Meaning
--redirect-uri URI http://127.0.0.1:8888/callback Must be one of your Spotify app’s Redirect URIs.
--env PATH the checkout’s .env The installation .env to read the data paths from.
Terminal window
autominer secret set SPOTIFY_CLIENT_ID
autominer secret set SPOTIFY_CLIENT_SECRET
autominer spotify authorize

Steps: it prints an address; open it in a browser logged in to your Spotify account and approve. The browser then goes to the redirect address (the page may not load). Paste the whole address from the address bar, or just its code. It stores the token only when Spotify granted user-read-playback-state (needed to see episodes played on your phone). Restart AutoMiner afterwards.

Changes data: one secret. Exit code 0 when stored; 2 when the client ID or secret is missing (nothing was changed) or the token was not stored, with the reason. More: Adding Spotify and podcasts.

A diagnostic for the Stremio tracker: resolves the parked (not yet matched) completions in a copy of the tracker’s state file and prints one JSON line each, without posting or saving.

Option Default Meaning
--state PATH required A copy of stremio_adapter_state.json (the live one is in $AUTOMINER_HOME/state/).
--cache PATH AUTOMINER_ANIBRIDGE_CACHE The AniBridge mapping cache to use, which it may refresh.
Terminal window
cp /var/lib/autominer/state/stremio_adapter_state.json /tmp/state-copy.json
autominer stremio-replay-dry-run --state /tmp/state-copy.json

Tracking now runs inside autominer serve. These commands start nothing; they print a note and exit 0. Remove any old systemd unit that still runs them.

Downloads the local judge (the pinned llama-server and one judge model, picked for this machine: d1-2B, about 1.1 GB, unless a GPU can run h2o-lightning-4B, about 2.7 GB) into $AUTOMINER_HOME/judge and checks each file’s SHA-256. See The judge for how the model is picked and checked. Running it again downloads nothing that is already complete.

Terminal window
autominer judge fetch

Changes data: yes (files in $AUTOMINER_HOME/judge). Exit code 0 when done; 1 with an ERROR: line when a download or check fails.

The web UI does the same: Settings › Services › Judge service › This machine › Download. After a download in the web UI, work held for the judge runs at once. After judge fetch, it runs when AutoMiner next starts, or at its next scheduled retry.

Source videos that AutoMiner downloaded can be deleted once their cards’ clips and pictures are made, or after a number of days (Settings › Sources › Media retention). Each source’s audio track, frames and clips stay, so re-cutting and checks still work.

Option Default Meaning
--commit off Queues the real sweep for the running server’s worker. Without it, a dry run.
Terminal window
autominer retention-sweep # what would go
autominer retention-sweep --commit # queue the deletion

The dry run prints the source IDs it would delete and would delete N source video(s), X GB, of M considered. With --commit it prints retention sweep queued (job <id>) (or already pending); the job appears in the web UI’s Workers panel as Clean up old videos.

Changes data: with --commit, it deletes video files. This cannot be undone. Only files in the sources store ($AUTOMINER_LIBRARY_ROOT/MineSrc/, or a remote store set with AUTOMINER_SOURCES_ROOT) are ever deleted, and nothing that is playing or being processed.

On the Raspberry Pi deployment a nightly timer runs retention-sweep --commit. Nothing else runs it: on an install.sh or Windows install, run it yourself (for example from cron; see Scheduling the nightly jobs).

Closes watch sessions whose client never sent an end (a tab that was closed, a phone that lost its connection). Watch time already recorded does not change.

Option Default Meaning
--older-than HOURS 6 Hours without activity before an open session counts as stale.
--dry-run on Reports and writes nothing. This is already the default.
--commit off Closes the stale sessions.
Terminal window
autominer session-sweep
autominer session-sweep --older-than 12 --commit

It prints one line per session and would close N of M open session(s); K left open (closed with --commit). Settings › Upkeep › Advanced › Session clean-up does the same.

Deletes every source recorded as verification data, and everything made from it (sessions, candidates, subtitle lines, jobs, files). Watches are recorded that way while the Chrome extension’s QA mode is on, and do not count on Today.

Option Default Meaning
--dry-run on Reports and writes nothing. This is already the default.
--commit off Deletes them.
--json off Prints the full report as JSON.
Terminal window
autominer qa-purge
autominer qa-purge --commit

Creates the database schema. It is safe to run twice. You do not need it: serve creates the database on its first start.

Rebuilds the watch-time intervals from the raw watch events.

Option Default Meaning
--session-id ID all sessions Rebuild one session only.

Changes data: yes. It prints N interval rows written.

These find, and repair, cards from older versions whose target word was stored in the wrong form. Run the scans first; only wordkey-repair --commit writes.

Command Options What it does
wordkey-scan --media-id ID, --json Lists automatic candidates whose katakana word was keyed on a kanji homophone that is not in the sentence. Read-only.
wordkey-repair --media-id ID, --dry-run (the default), --commit, --no-enrich, --json Re-keys the rows the scan finds and clears their old dictionary data. Protected rows (already in Anki, approved or rejected, or linked to a note) are left alone. With --commit it also looks the words up in Yomitan again, unless --no-enrich.
target-scan --media-id ID, --json Lists automatic candidates whose stored word is an inflected form rather than the dictionary form. Read-only.
Terminal window
autominer wordkey-scan
autominer wordkey-repair --commit

These are for a server that is upgraded by a script, such as the Raspberry Pi deployment. The checkout’s deploy/safe-deploy.sh runs them in order.

Closes new-work admission, waits for running work to finish, and reopens it afterwards. While admission is closed, new requests are accepted and held (the web UI shows a Maintenance banner, and held jobs say Runs after maintenance).

Subcommand Options What it does
status --json Shows the admission state and how many jobs are running, queued and held.
begin --owner NAME (required), --token TOKEN, --json Closes admission and prints the token that owns it.
drain --token TOKEN (required), --timeout SECONDS (900), --poll SECONDS (2), --abort-on-timeout, --json Waits for admitted work to finish. Exits 4 if it is still running after the timeout; --abort-on-timeout reopens admission first.
assert-closed --token TOKEN (required) Exits 0 only if admission is closed, drained and held by this token.
reopen --token TOKEN, --force, --json Reopens admission and releases held jobs. --force reopens a pause whose owner is gone; it is still refused while a job runs.
Terminal window
autominer maintenance status
autominer maintenance reopen --token <token>

Changes data: the admission state in the database. If an interrupted upgrade left admission closed, status shows it and reopen ends it.

Command Options What it does
release-gate --pr N (required, repeatable), --target SHA (required, 40 characters), --core-url (http://127.0.0.1:8801), --repo DIR (.), --remote-ref (origin/master), --github-repo OWNER/NAME (the upstream repository), --accept-producer-loss TOKEN, --json Decides whether an approved commit must be deployed: exit 0 deploy, 3 nothing to do (the running server already has those PRs), 1 blocked. It reads the running revision from /healthz and looks up the PRs with the gh CLI.
verify-deployed --target SHA (required), --token TOKEN, --core-url, --json Exits 0 only when /healthz reports the approved commit, a clean tree, and admission still drained and owned.

Neither changes data.

Shows which clients (the extension, the phone patch, the trackers) post watches here, and manages who may.

Form What it does Changes data?
producers or producers status Whether every recently active client keeps what it cannot deliver during a restart. Exit 0 if so, 1 if not. Reads the running server. No
producers list The policy, enrolled clients, clients seen, and refused posts. No
producers approve NAME Enrols a client identity. Yes
producers revoke NAME Withdraws an enrolment (the record is kept). Yes
producers policy Shows the admission mode; with --set changes it. With --set

Options: --json, --core-url (http://127.0.0.1:8801), --days N (14: days of silence before a client stops counting), --min-contract N, --require-build, --expires YYYY-MM-DD, --note TEXT, --operator NAME, --set permissive|observe|enforce (unconfigured: permissive), and --confirm TOKEN (required to turn enforce on; the refusal prints the value to use). Details: Producer admission.

The Start-menu entry runs pythonw.exe -m autominer.desktop, not autominer serve. It sets AUTOMINER_HOME to %LOCALAPPDATA%\AutoMiner\data (unless you set it), starts the server with its output in logs\autominer.log, and opens the browser.

Option Default Meaning
--background off Starts without opening the browser (used for the start at sign-in).
--no-browser off Does not open the browser.
--host 127.0.0.1 Address to listen on.
--port 8801 Port to listen on.

If AutoMiner is already running on that port with the same data, it only opens the browser. If another program holds the port, it shows a message and exits.

Set a variable in front of one command to try a value (ANKICONNECT_URL=http://<anki-computer>:8765 autominer doctor). For the service, see the note under setup. A blank value counts as unset. The full list, with every default, is autominer help settings --all and Configuration.

Variable Default What it changes
AUTOMINER_HOME /var/lib/autominer as root, else ${XDG_DATA_HOME:-~/.local/share}/autominer; the Windows launcher uses %LOCALAPPDATA%\AutoMiner\data The data directory. Every path below derives from it.
AUTOMINER_DB $AUTOMINER_HOME/autominer.db The database file.
AUTOMINER_LIBRARY_ROOT $AUTOMINER_HOME/library Clips, pictures, caches, and downloaded sources unless the next one is set.
AUTOMINER_SOURCES_ROOT blank: $AUTOMINER_LIBRARY_ROOT/MineSrc Where downloaded videos and podcast audio go, for example a mounted NAS share carrying a .autominer-sources file.
AUTOMINER_SECRETS_DIR $AUTOMINER_HOME/secrets Where secret set and the web UI store keys.
NAME_FILE (for example OPENAI_API_KEY_FILE) blank Reads that secret from another file.
AUTOMINER_CORE_URL inside serve: its own address; otherwise http://127.0.0.1:8801 Where the trackers post, and where doctor looks for the running server. The deployment commands and producers take --core-url instead.
AUTOMINER_LANG blank: the languages saved in Settings, else ja The studied languages, comma separated, first is the primary one.
AUTOMINER_TRACKING on 0 runs no Stremio or Spotify tracker (for a test copy that holds real credentials).
ANKICONNECT_URL http://127.0.0.1:8765 AnkiConnect’s address. A URL saved in Settings › Services wins over it.
AUTOMINER_YOMITAN_URL blank A Yomitan API server. It wins over the URL saved in Settings.
AUTOMINER_YOMITAN on 0 switches dictionary lookups off.
AUTOMINER_YOMITAN_BUILTIN auto The built-in Yomitan: auto uses a Yomitan API answering at 127.0.0.1:19633, else starts the built-in one; 1 always starts it; 0 never.
AUTOMINER_YTDLP blank: the yt-dlp AutoMiner downloaded, then the venv’s, then PATH, then /usr/local/bin/yt-dlp The yt-dlp program.
AUTOMINER_VPN_PROXY blank An HTTP proxy whose exit is your VPN.
AUTOMINER_YOUTUBE_VPN fallback fallback retries a refused YouTube call through the proxy (and keeps to it for 6 hours); always; off.
AUTOMINER_PORT 8801 Read by install.sh only: the port written into the service it installs.

Where a live value comes from, first match wins: the process environment; the rendered environment file the service reads ($AUTOMINER_HOME/env/*.env); for secrets, the secrets directory; the default. autominer doctor names the source of each one.