Skip to Content
CLIAdmin & policycmdop session

Sessions

A session is the durable backing of a remote terminal: a PTY plus a ringbuffer plus an idle TTL. Sessions outlive the client. Detach with Ctrl+D and the session keeps running on the target machine; reattach interactively from anywhere with cmdop connect.

Interactive (live PTY) reattach today is done with cmdop connect <host>. The cmdop session attach <id> command currently prints the session’s metadata (shell, working directory) and marks it attached — an interactive shell takeover over session attach is on the roadmap, not yet implemented.

What a session is

When you cmdop connect vps-audi, the daemon spawns or reuses a session on vps-audi and gives you a live interactive terminal. The session owns the PTY, the running processes, and a scrollback ringbuffer. Closing the client doesn’t kill the session — it survives until you destroy it or the idle TTL expires.

Create / list

cmdop session create vps-audi --name deploy cmdop session list # all your sessions cmdop session list --host vps-audi cmdop session list --json

A bare cmdop connect vps-audi also creates a session implicitly — cmdop session create is for when you want to script the creation without attaching immediately.

Attach / detach

cmdop session attach 0193e2c1-7a8f-7b33-8c01 # prints metadata, marks attached cmdop session attach deploy # by name (if unique on this host) cmdop session detach 0193e2c1-7a8f-7b33-8c01

cmdop session attach currently reports the session’s metadata and marks it attached; it does not yet open an interactive shell over the session. For a live terminal, use cmdop connect <host> — that reattaches to the running session interactively. Interactive takeover via session attach (including a --takeover flag to force-detach other clients) is planned, not yet implemented.

Save / restore

cmdop session save 0193e2c1-... --to ./session-snapshot.json cmdop session restore --from ./session-snapshot.json

save snapshots the ringbuffer (last N lines) and PTY metadata. restore is for migrating session metadata between machines — rare, mostly for internal tooling.

Destroy

cmdop session destroy 0193e2c1-7a8f-7b33-8c01 cmdop session destroy --idle 24h # nuke all idle for >24h

Destroy kills the PTY and removes the ringbuffer. Sessions also auto-expire after the configured idle TTL (default 7 days).

Triggers vs sessions

Both live under cmd/cmdop/cmds/session/ because both are stateful CLI concepts:

SessionsTriggers
TriggerOperator attachCron schedule
LifetimeIdle TTLUntil disabled
OutputLive PTYLogs + Board entry
Use forInteractive workScheduled automation

See ./trigger for the scheduled-task surface.

Inspecting session ringbuffers

cmdop session show 0193e2c1-... # metadata cmdop session show 0193e2c1-... --tail 200 # last 200 lines of scrollback

Useful for “what was on screen 4 hours ago?” without reattaching.

Troubleshooting

  • “Session shows attached but no input echoes”cmdop session attach reports metadata only; for a live interactive terminal use cmdop connect <host>. If another client holds the live PTY, detach it from that client (force-detach via session attach takeover is planned, not yet implemented).
  • “Session disappeared” — check the idle TTL in ~/.cmdop/config.yaml; default is 7 days.
  • “Cannot create session: target offline” — confirm the target with cmdop connect --list; remote daemon must be running.
Last updated on