Stop Killing Long AI Jobs When You Close the Laptop Lid
TL;DR
- Run the long job inside tmux on an always-on xshellz.box, then detach: the box keeps running 24/7 with zero idle timeout, even on the free tier.
- tmux sessions survive SSH disconnects and laptop sleep; press Ctrl-b then d to detach, and
tmux attach -t <name>to reconnect.- The box ships with Python 3, Node 22, and six preinstalled coding agent CLIs, so a heavy agentic run needs nothing installed first.
Run the task inside tmux on an always-on remote box, not on your laptop. SSH into an xshellz.box, start a tmux session, launch your agent or script, detach, and close the laptop. The box keeps running 24/7 on every tier, including free, with zero idle timeout, so nothing stops when you disconnect. We run this exact setup on our own fleet at xShellz, and the boxes we ship come with tmux and six coding agent CLIs preinstalled.
how can i run a long ai task in the terminal without it stopping when i close my laptop?
Change where the process lives. A process on your laptop dies the moment your SSH session drops or the lid closes. A process on an always-on box inside a tmux session does not. The Agent Shell is a hardened Ubuntu 24.04 box that runs 24/7, on every tier including free, with no idle timeout and no trial countdown.
ssh -p <port> root@<host> # connect to the box
tmux new -s job # start a named tmux session
borg "refactor the auth module and run the full test suite"
Then press Ctrl-b, release, press d to detach. Close the laptop. The job keeps running. Reconnect later with tmux attach -t job and the output is still there.
how to run background tasks in a remote linux shell
A plain & background job is still owned by your SSH session, and a dropped connection sends it a hangup signal that kills it. On a remote box the reliable pattern is to start the task inside tmux from the beginning, which detaches the process from the SSH session entirely. tmux is preinstalled on every xshellz.box, along with git, ripgrep, htop, vim and build-essential, so there is nothing to install before you start.
tmux new -s scrape
python3 scraper.py # or borg "scrape the data, then summarize"
The session runs independently of your connection. You can run a long process the same way with any of the six preinstalled agents: borg, Claude Code, Codex, Gemini CLI, opencode or pi.
how to use tmux to keep a process running after ssh disconnect
tmux runs a server process on the box that holds your shells open even when the SSH client goes away. You attach to a session to watch it and detach to leave it running, which is exactly what you want for a six hour agent run. The detach binding is Ctrl-b then d; attach back with tmux attach -t job, and create as many named sessions as you need.
tmux new -s irc irssi # an IRC client that stays connected after logout
tmux attach -t irc # come back to it later
tmux ls # list running sessions
The tmux manual covers every binding and option (https://man.openbsd.org/tmux). Because the box itself never sleeps, the session stays alive until you kill it, not until your laptop does.
can i run heavy python scripts on a remote server via terminal
Yes, and on an xshellz.box you do not start by installing the runtime. Every box ships with Python 3, Node 22, build-essential, git, ripgrep and more on Ubuntu 24.04 LTS (https://ubuntu.com/about/release-cycle). Long, CPU heavy jobs like scraping, model inference or large scale refactors run on the box's CPU while your laptop stays idle, which is the whole point of offloading.
To reproduce your environment on a new box, write an xshellz.box manifest in your home directory, one line per package: a bare name uses apt, or prefix with pip: or npm:. The manifest reinstalls on every boot, so every box is the same environment.
Two Python agent frameworks, crewai and langgraph, are already installed system wide under Python 3, so you can import crewai with no venv and no pip wait.
what is the best way to offload ai agent compute from my laptop
An always-on box that already has the agents installed. Churning through a large codebase with an agent is exactly the kind of job that should not depend on your laptop staying awake and connected. The Agent Shell ships with six coding agent CLIs preinstalled and configured for bring-your-own-key use: borg, Claude Code, OpenAI Codex, Gemini CLI, opencode and pi. Log in once and pick the one you like.
borg is our own terminal agent, a single static Go binary with no runtime to install. Start it with borg "fix the failing test" for a one shot task, borg learn to study a repo, or borg --resume to continue the most recent session. It works with Ollama, LM Studio, OpenAI, OpenRouter, or the four hosted xShellz models: Chuppa Flash, Chuppa Pro, Floko and Axiom.
Frequently asked questions
What happens to my running job if the box itself is rebuilt?
A tmux session lives in the box's memory, so a rebuild on a newer image stops running processes. Only /root persists across rebuilds; the rest of the filesystem is ephemeral and resets. Keep your code and data in /root, put your dependencies in the xshellz.box manifest so they reinstall on every boot, then re-run the job.
Do I need my own API key for the preinstalled coding agents?
The six agents are bring-your-own-key: point them at Ollama, LM Studio, OpenAI or OpenRouter. To use the hosted xShellz models instead, run borg auth login (add --device on a headless box) and pick from Chuppa Flash, Chuppa Pro, Floko or Axiom.
Can I wire the box into Claude Code on my laptop?
Yes. Add it as an MCP server over SSH with one command: claude mcp add xshellz -- ssh -p <port> agent@<host> xshellz-mcp. Then Claude Code on your laptop can drive the box as a remote environment while the heavy work runs there.