You bought a Mac mini, or you are about to, for one reason: you want your Claude Code agent to keep working after you shut your laptop. It sits on a shelf, always plugged in, always awake, chewing through a refactor while you sleep. It works. It also cost you $599 up front to do a job a $5 server does better. If you have been searching how to keep claude code agent running 24/7 without a mac mini, the short answer is a small Linux box in the cloud that you never have to dust, plug in, or carry home.
The mini is not a bad computer. It is just the wrong tool for "always-on." You are buying silicon, power, and a spot on your desk to solve a problem that is really about one thing: keeping a process alive after the terminal that started it goes away. That does not need Apple hardware. It needs a host that stays up and a supervisor that refuses to let the process die.
The Mac mini tax nobody warns you about
A Mac mini as an agent box costs more than the sticker. You pay for the machine, you pay for power around the clock, and you pay in attention. It lives on your network, so a home internet outage or a router reboot at 2am kills the long job you were counting on. You are the one who patches macOS, reboots after an update, and notices three days later that the agent stopped because a launchd job was not configured to relaunch it.
There is also the reachability problem. Your Claude Code agent on a mini under your desk is trapped behind a residential connection with a rotating IP. Checking on it from your phone while you are out means punching holes in your home firewall or setting up a tunnel. A cloud server hands you a stable public IP and SSH on day one. You get the same "it runs while I sleep" outcome without owning, powering, or babysitting a physical box.
And the mini is a single point of failure you happen to live with. One drink spilled near it, one thermal shutdown during a heatwave, one power strip someone kicks loose, and the "always-on" agent is off until you get home. A $5 droplet lives in a datacenter with redundant power and cooling, and if the whole instance dies you rebuild it from a snapshot in minutes instead of ordering a replacement logic board. For a hobby project the mini is genuinely fun. For anything you depend on, you have quietly made yourself the on-call hardware team.
How to keep Claude Code agent running 24/7 without a Mac mini
The real question, how to keep claude code agent running 24/7 without a mac mini, comes down to one fix repeated across every setup: stop your terminal from owning the process. When you launch claude in an SSH session and close your laptop, your shell gets a hangup signal and takes the agent down with it. Move ownership to something that outlives your session and the agent keeps going.
Two tools do this on any Linux host. A terminal multiplexer, tmux, keeps an interactive session running on the server after you detach or disconnect. A service manager, systemd, runs the agent as a background daemon and restarts it on crash or reboot. Claude Code itself runs fine on Linux; Anthropic's Claude Code documentation covers installation and the headless print mode you will use for automation.
That gives you three honest routes, cheapest and most hands-on first:
A cheap VPS with
tmuxfor interactive, hands-on runs.The same VPS with a
systemdservice for set-and-forget, self-healing runs.A managed always-on runtime if you would rather not run a server at all.
Option 1: A $4-6/month VPS with tmux
Rent a small virtual server and you have a stable, always-on Linux box for the price of a coffee. A Hetzner CX22 runs about 4 EUR a month for 2 vCPU and 4 GB of RAM; DigitalOcean, Vultr, and Linode all sell basic droplets in the $4 to $6 range. That is plenty, because the heavy lifting happens in Anthropic's API, not on your server. Your box mostly holds the repo, runs git, and keeps the session alive.
Spin up Ubuntu, SSH in, install Node and Claude Code per the docs, then add tmux:
# Debian/Ubuntu
sudo apt update && sudo apt install -y tmux
# Start a named, detached session and launch Claude Code inside it
tmux new-session -d -s claude
tmux send-keys -t claude "cd ~/project && claude" Enter
# Reattach from your laptop or phone, over SSH, from anywhere
tmux attach -t claude
# To leave it running: press Ctrl-b, release, then press d to detach# Debian/Ubuntu
sudo apt update && sudo apt install -y tmux
# Start a named, detached session and launch Claude Code inside it
tmux new-session -d -s claude
tmux send-keys -t claude "cd ~/project && claude" Enter
# Reattach from your laptop or phone, over SSH, from anywhere
tmux attach -t claude
# To leave it running: press Ctrl-b, release, then press d to detachThe trick is ownership. The claude process now belongs to the tmux server on the VPS, not to your SSH connection. Close your laptop, lose Wi-Fi on a train, quit your terminal app entirely, and the agent keeps working. When you are back, tmux attach -t claude drops you right back into the live session with the scrollback intact. This is the same reason your agent should not die the moment you shut the lid, which we dig into in keeping an agent running after you close your laptop.
Checking on the agent from your phone
This is where a cloud box quietly beats the mini. Because the VPS has a public IP, any SSH client on your phone reaches it. Install an app like Termius or Blink, save the host and your key once, and you can open the live session from a coffee shop:
ssh agent@your-vps-ip
tmux attach -t claudessh agent@your-vps-ip
tmux attach -t claudeYou see exactly what Claude Code is doing right now, type a follow-up if it stalled, then detach and pocket the phone. No home firewall holes, no tunnel, no dynamic-IP guessing game. Try that with a Mac mini behind a consumer router and you are configuring port forwarding at 11pm.
The honest tradeoff: tmux does not restart anything. If Claude Code crashes, or the VPS reboots for a kernel security update, the session is gone and you re-launch by hand. For interactive work where you are checking in a few times a day, that is fine. For truly unattended runs, reach for systemd.
Option 2: A systemd service with Restart=always
For set-and-forget, let systemd own the agent. Restart=always brings the process back within seconds if it crashes, and WantedBy=multi-user.target brings it back after a reboot. This suits a headless agent: a wrapper script that feeds Claude Code a task in print mode and loops. Create the unit at /etc/systemd/system/claude-agent.service:
[Unit]
Description=Claude Code agent, always on
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=agent
WorkingDirectory=/home/agent/project
EnvironmentFile=/etc/claude-agent.env
ExecStart=/usr/local/bin/run-agent.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target[Unit]
Description=Claude Code agent, always on
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=agent
WorkingDirectory=/home/agent/project
EnvironmentFile=/etc/claude-agent.env
ExecStart=/usr/local/bin/run-agent.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetKeep your key out of the unit file. Put ANTHROPIC_API_KEY=sk-ant-your-key-here in /etc/claude-agent.env and lock it down with chmod 600. The wrapper script runs Claude Code headless against a task file and loops:
#!/usr/bin/env bash
set -euo pipefail
# Feed the agent the next task, headless, then pause and repeat.
while true; do
claude -p "$(cat /home/agent/project/next-task.md)" \
--permission-mode acceptEdits \
--output-format text >> /home/agent/agent.log 2>&1
sleep 30
done#!/usr/bin/env bash
set -euo pipefail
# Feed the agent the next task, headless, then pause and repeat.
while true; do
claude -p "$(cat /home/agent/project/next-task.md)" \
--permission-mode acceptEdits \
--output-format text >> /home/agent/agent.log 2>&1
sleep 30
doneMake it executable, then enable and watch it:
sudo chmod +x /usr/local/bin/run-agent.sh
sudo systemctl daemon-reload
sudo systemctl enable --now claude-agent
journalctl -u claude-agent -fsudo chmod +x /usr/local/bin/run-agent.sh
sudo systemctl daemon-reload
sudo systemctl enable --now claude-agent
journalctl -u claude-agent -fRestart=always with RestartSec=5 is the whole self-healing story. The systemd.service documentation covers the extras worth adding for a real deployment: StartLimitBurst to stop a crash loop from hammering the API, MemoryMax to cap a runaway process, and Type=notify for cleaner startup signaling.
Two honest cautions. First, a permission mode like acceptEdits lets the agent act without prompting you, which is what makes headless automation possible and also what makes a tight task scope and a non-root agent user non-negotiable. Second, Claude Code's interactive REPL wants a TTY, so systemd fits the headless loop pattern above. If you want the interactive experience unattended, run the tmux session from Option 1 and, if you like, have a small systemd unit relaunch that tmux session on boot. Pick the model that matches how you actually use the agent.
Mac mini vs VPS vs managed runtime: the honest comparison
None of these is universally best. They trade money for time and control in different ways. Here is the shape of it:
| Approach | Up-front cost | Monthly cost | Effort to run | Survives crash and reboot |
|---|---|---|---|---|
| Mac mini on a shelf | ~$599+ | power plus your time | you patch it, reboot it, tunnel to it | only if you wire up launchd yourself |
| $4-6 VPS with tmux | $0 | $4-6 | reattach over SSH, restart by hand | no, you re-launch after a reboot |
| $4-6 VPS with systemd | $0 | $4-6 | configure once, then leave it | yes, Restart=always plus boot start |
| Managed always-on runtime | $0 | flat plan, from $12 | almost none | yes, and the agent's files persist |
The VPS-plus-systemd row is the sweet spot for most people: a few dollars a month, self-healing, reachable from anywhere, and no hardware to own. If you would rather not run a server at all, there is a fourth option, with one honest caveat: a managed runtime like Sokko does not host Claude Code itself. Sokko deploys one of its four ready-made agent runtimes (OpenClaw, Hermes, Paperclip, OpenSRE) from the dashboard in a couple of clicks, with the always-on, restart, and storage pieces handled for you and no VPS to patch; you bring your model keys or use Sokko credits. If what you actually need is an assistant or agent that stays up around the clock, that is the zero-ops path. If it has to be Claude Code specifically, stick with the VPS rows above.
Which setup should you actually pick?
Start with what you already own. If a Mac mini is sitting on your desk, keep using it. Configure a launchd agent so the process relaunches, and do not go buy a second machine. The waste is buying hardware only to get "always-on," when a $5 server delivers it with a public IP and datacenter uptime for a fraction of the money.
If you are choosing fresh, the practical answer to how to keep claude code agent running 24/7 without a mac mini is: rent a small VPS, pick tmux for hands-on sessions or systemd for unattended ones, and reattach from your phone whenever you want to check in. Reach for a managed runtime when you would rather skip OS patching, backups, and monitoring entirely and just have an agent stay up.
Size the money before you commit. A VPS saves you the up-front hardware cost and lands around $4 to $6 a month; a managed runtime costs more per month but hands you back the ops time. If you want hard numbers across every path, we break them down in what it actually costs to run an agent around the clock. For the wider picture of every way to keep an agent alive, not just Claude Code, see how to run an AI agent 24/7 without babysitting a server.
Where to go next
Pick one path and prove it today. Spin up a $5 VPS, install Claude Code, and start it inside tmux. Close your laptop, wait an hour, then tmux attach and watch it still working. Once that clicks, promote the important runs to a systemd service with Restart=always so a crash or a reboot never leaves you with a dead agent and no idea why. The Mac mini can go back to being a desktop, or back in the box, because keeping Claude Code running around the clock never needed it.