Skip to content

Remote commands

Run commands on your environment without keeping a terminal session alive. qc exec executes the command server-side in a one-off container, so the run survives laptop sleep, dropped connections, and closed terminals — the CLI only watches progress.

qc ssh --command qc exec run
Where it runs Inside the live container, over an interactive session In a one-off container, server-side
Laptop sleeps mid-run Command is killed Run continues
Interactive input Yes No
Exit code in scripts Yes Yes
Run length As long as the session holds Up to 1 hour

Use ssh for interactive work (shells, REPLs, debugging). Use exec for anything long-running or unattended: cron-style jobs, imports, migrations, cache rebuilds.

Terminal window
qc exec run "drush cron"

The CLI prints a run ID immediately, then streams output as the run progresses:

✔ Command created (runId: 411fc62f-b8d5-4d7c-b8af-5a53f371d222)
Regenerating cache...
Processed 1000 items
✔ Completed (exit 0) in 4m 02s

Container startup adds roughly a minute before the first output appears. The remote exit code becomes the CLI’s exit code, so failures propagate to scripts and CI.

Nothing to do — this is the default behavior. If your machine sleeps while watching, the run continues on the server; when you wake, the CLI’s next poll picks up where things stand. If the CLI process died entirely, reattach:

Terminal window
qc exec status <runId> --watch

Reattaching reprints the run’s accumulated output from the beginning, then streams new lines live.

Start a run and return immediately:

Terminal window
qc exec run "./import.sh" --detach

Check on it later — from the same machine or any other machine with CLI access:

Terminal window
qc exec status <runId> # one-shot check
qc exec status <runId> --watch # attach until it completes

Pressing Ctrl+C while watching only detaches the CLI; the run itself is unaffected.

If your environment runs multiple containers, pick one (defaults to the first in the task definition):

Terminal window
qc exec run "php artisan migrate --force" --container php

Commands with shell operators (&&, ;, |, …) are automatically wrapped in /bin/sh -c on the server. Write them flat — don’t nest your own sh -c quoting:

Terminal window
# Good
qc exec run "echo start && ./migrate.sh"
# Avoid — nested quoting gets mangled
qc exec run "sh -c 'echo start && ./migrate.sh'"
  • Runs are capped at 1 hour; longer runs finish with status TIMED_OUT. For recurring work, use scheduled cron jobs on the environment instead.
  • Runs are non-interactive — commands that prompt for input will hang until the cap.

See the qc exec command reference for all flags.