ssh_run_persistent
Run remote commands that persist after connection loss, with logged output and process monitoring.
Instructions
Run a command on the remote host that SURVIVES MCP disconnect, Zed restart, or any interruption to the current session. The process runs via nohup in the background; its stdout and stderr are saved to log files on the remote server.
Returns immediately with the remote PID and log file paths. Check progress later with ssh_persistent_status or manually: ssh_exec('tail -n 50 /tmp/mcp-persistent//out.log') ssh_exec('ps -p -o pid,stat,etime,cmd --no-headers || echo DEAD')
WHEN TO USE THIS (not ssh_spawn):
Multi-hour or overnight tasks (training runs, large parsers, database migrations, long builds).
Any task where losing the MCP connection would be catastrophic.
Tasks you want to start now and check on later.
WHEN TO USE ssh_spawn INSTEAD:
You need real-time streaming output in chat.
The task takes under ~10 minutes and you will stay connected.
NOTE: logs are NOT auto-deleted. Clean up manually with: ssh_exec('rm -rf /tmp/mcp-persistent/')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | The shell command to run. Passed to ``bash -c``. Compound commands (``&&``, ``|``, subshells) work normally. | |
| host | No | Alias of the configured host, or its raw address. If omitted, the default host is used. | |
| label | No | Optional human-readable tag stored in the log dir alongside the command for future reference. | |
| work_dir | No | Base directory on the remote where per-job subdirectories are created. Default ``/tmp/mcp-persistent``. Use a path outside ``/tmp`` for jobs that must survive a server reboot. | /tmp/mcp-persistent |
| env | No | Optional environment variables set before the command. Names must match ``[A-Za-z_][A-Za-z0-9_]*``. | |
| cwd | No | Optional remote working directory (``cd`` before running). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||