ti exec
ti exec runs a command against a TiDB Cloud Filesystem without mounting the Filesystem locally. Output streams to your terminal; the remote exit status is preserved.
Prerequisites
- Install TiDB Cloud CLI v0.2.11 or later with an up-to-date
ti-drive9companion. Earliertireleases do not includeti exec. Runti --versionto check your installed version. - Create a Filesystem in a supported region and retain its ID and owner token.
- Use a locally stored token for that ID, or set
TI_FS_TOKENin your environment. Prefer the environment variable over--fs-tokento avoid exposing it in arguments. A delegated Vault token cannot run commands. Path-scoped tokens cannot mount a sandbox. ti exec --helpchecks only that the local command exists. It does not verify the companion or remote Runtime. Both must support exec.
Upgrade an existing installation
Before upgrading, stop writers and unmount any Filesystem or Vault mounts. On macOS or Linux with a user-owned installation of ti, update to the latest release and verify the version:
ti update
ti --version
ti exec --help
When ti update installs a different ti version, it also replaces the ti-drive9 companion. If ti is already at the requested version, the updater does not refresh the companion. To refresh an outdated companion on macOS or Linux, rerun the shell installer; use --install-dir to retain a custom installation directory.
On Windows, rerun the PowerShell installer; in-place self-update is unsupported. For installation steps, see Install TiDB Cloud CLI.
Syntax and execution
ti exec [options] [--] command [arg...]
ti exec [options] 'shell command line'
Put ti options before the remote command. Arguments after it, including --help, belong to the remote command. A single shell command line is interpreted by /bin/sh -c; multiple arguments are passed directly.
The server selects the execution backend. Commands supported by the lightweight shell executor can run without starting a sandbox. Other commands use a sandbox before execution begins. Shell syntax alone does not determine the backend. A command that has started is never retried on another backend after failure.
The Filesystem is available at /workspace. Files outside /workspace are temporary. --fresh starts a new sandbox while keeping Filesystem data. -w chooses a working directory; it does not restrict access to that directory.
Example: process and read back a file
Requires a POSIX-compatible shell locally and Python 3 remotely.
export TI_REGION_CODE=aws-us-east-1
export TI_FS_FILE_SYSTEM_ID='<file-system-id>'
workdir="runtime-demo-$(date +%s)"
ti fs create-directory --path "/$workdir"
# Inspect the directory without permitting writes.
ti exec --read-only -w "$workdir" ls
# Process data remotely and save the result in the Filesystem.
ti exec -w "$workdir" python3 -c \
'from pathlib import Path; Path("result.txt").write_text("total=42\n")'
# Start a new sandbox and read the saved result.
ti exec --fresh -w "$workdir" cat result.txt
Expected output:
total=42
Verify independently, then remove the example directory:
ti fs read-file --path "/$workdir/result.txt"
ti fs delete-file --path "/$workdir" --recursive
Options
Inside a matching ti-created FUSE mount, omitting -w uploads pending local writes and follows the current directory. Explicit -w does not upload local changes first. For a WebDAV mount, pass -w explicitly.
Failures and limitations
A completed command returns its exact exit status. With an up-to-date ti-drive9 companion, interpret the following statuses together with the error message:
Commands can themselves return these numbers, so the exit status alone does not identify the cause.
- Remote stdin and interactive terminals are unsupported.
--output,--query, and--dry-runare unsupported. - Press Ctrl-C once to request cancellation and wait for confirmation. Pressing it again detaches; the command might still be running.
- If the outcome is unknown, inspect the Filesystem before deciding whether to run the command again. Disconnection or a missing execution record does not prove that execution stopped.
ti execnever retries automatically.