What 24/7 actually requires
Most guides stop at "put it on a server." That gets you an agent that is reachable 24/7, not one that is useful 24/7. A genuinely always-on agent needs four things:
- Always-on compute. A machine that never sleeps. Your laptop is disqualified by design: lids close, batteries die, operating systems suspend everything on sleep. The process has to live somewhere that stays powered and connected.
- Crash recovery. Agents crash. They hit out-of-memory limits, an API times out mid-call, a dependency update breaks them at 2am. Something must notice the dead process and restart it without you.
- Persistent memory. If the agent forgets everything on restart, recovery is pointless. State needs to live on disk (or in a database), not in the process. A restarted agent should pick up its task list, its context, and its history.
- A proactive channel. An agent working overnight is useless if the results sit in a terminal you are not looking at. It needs a way to reach you: Telegram, Discord, email, a webhook. Without one, you built a very expensive cron job that talks to itself.
Miss any one of these and you do not really have a 24/7 agent. You have an agent that works while you happen to be watching it. This article covers how to build each layer yourself, and where the shortcuts are. For the broader hosting decision, the AI agent hosting guide is the pillar piece.
The option matrix: laptop hacks vs VPS vs managed
There are three places an always-on agent can live. Here is how they compare on the four requirements:
| Laptop + caffeinate | DIY VPS | Managed (Hivra) | |
|---|---|---|---|
| Always-on compute | No. Sleep, reboots, and travel all kill it | Yes | Yes |
| Crash recovery | Manual | You build it (systemd, healthchecks) | Handled |
| Persistent memory | Survives until you reinstall | You configure the volume | Persistent workspace per agent |
| Proactive channel | You wire it | You wire it | Telegram and channel connect built in |
| Cash cost | $0 | $5-15/mo | $0 free tier, $9.99/mo always-on |
| Your time | Constant babysitting | 2-4 hours setup, ongoing patching | ~5 minutes |
The laptop route deserves one honest sentence: caffeinate on macOS and disabled sleep on Windows keep the machine awake, but the first reboot, network change, or forced OS update ends the run. It is fine for a single overnight task. It is not an architecture.
The DIY VPS route works and this guide covers everything you need to build it. The managed route runs the same agents on a private VM with the recovery, memory, and channel layers already wired. Both are legitimate. The difference is whose pager goes off when the process dies.
Scheduling: cron, heartbeats, and routines
A 24/7 agent that only reacts to messages is idle 95% of the time. Scheduling is what turns uptime into output. Three patterns, in order of sophistication:
OS cron. The blunt instrument. Fire a headless agent run on a schedule:
Cron is reliable and boring. Its weakness: every run starts cold. No memory of the previous run unless you build state passing yourself.
Heartbeats. The agent wakes on a short interval (every 15 or 30 minutes), reads a checklist file, decides if anything needs doing, and goes back to sleep. This is how an agent checks your inbox, watches an RSS feed, or monitors a deploy without a human prompt. The key property: the agent decides what to do at wake time, using current context, instead of executing a frozen command.
Agent-native routines. Frameworks like Hermes ship a scheduler inside the agent itself, so recurring jobs live in the agent's own memory and survive restarts with their context intact. That closes the cold-start gap cron leaves open. The full setup is covered in Hermes Agent scheduled tasks.
Rule of thumb: cron for fixed jobs that never need context, heartbeats for watch-and-react work, native routines when the agent should own its own calendar.
Monitoring and auto-restart
On a DIY box, systemd is the standard answer for keeping the process alive:
Restart=always handles crashes. MemoryMax stops a leaking agent from taking the whole box down with it. Enable with systemctl enable --now agent.
Restart-on-crash is necessary but not sufficient. The failure modes that actually kill long-running agents are quieter:
- Disk fills up. Logs and browser caches grow forever. Rotate logs (
logrotate) and cap cache directories, or the box dies in week three. - The process is alive but stuck. A hung API call or a deadlocked loop passes every process check. You need a liveness probe that exercises real behavior: hit the agent's API and expect a response, instead of settling for a live PID.
- Silent auth expiry. Tokens and sessions expire. The agent runs, every task fails, nothing restarts because nothing crashed. Alert on task failure rate, not just uptime.
Not sure whether your current setup survives these? The agent survival check walks through the failure modes in about a minute and tells you which ones would take your agent down.
Running multiple agents on one box
Once one agent earns its keep, you will want a second. A research agent, a coding agent, one per project. Cramming them onto one VPS is where DIY setups start to hurt:
- Resource contention. One agent spins up a browser and eats 2 GB of RAM. The other agents start getting OOM-killed. Now you are writing cgroup limits.
- Dependency collisions. Agent A needs Python 3.12, agent B's install script upgrades it to 3.13, agent A stops booting. Containers fix this, at the cost of you now maintaining Docker.
- Shared blast radius. A bad update or a disk-full event takes out every agent at once, instead of one.
The clean pattern is isolation: one VM (or at minimum one container) per agent, each with its own filesystem, its own memory limit, and its own lifecycle.
That isolation is the managed model. On Hivra, each agent runs on its own private VM, so one agent's browser binge cannot starve another. The Pro plan at $9.99/month runs up to 3 agents, Power at $19.99/month runs up to 5, and the catalog covers six agents: Hermes, Claude Code, Codex, Aeon, OpenClaw, and Agent Zero. For the last two, Agent Zero vs OpenClaw hosting covers what each needs from a box and which plan fits. Mixing them is normal. A common stack is Hermes as the always-on operator plus Claude Code for repo work.
What 24/7 duty cycle actually costs
Split the cost into the two lines that behave differently:
Infrastructure is flat. A box that runs 24/7 costs the same whether the agent does one task or a hundred. DIY: $5-10/month for a small VPS running a CLI agent, more like $10-15/month once you add a real browser, because Chrome wants 1-2 GB of RAM to itself. Managed: Hivra's free tier is $0 (one agent, sleeps after 4 idle days, no browser), Pro is $9.99/month for always-on with up to 3 agents.
Inference scales with activity, not uptime. This is the part people get wrong. An idle agent sitting at a prompt burns zero tokens. You pay for model usage when the agent works, so "running 24/7" does not mean "paying for inference 24/7." A heartbeat every 30 minutes with a short check is cheap. An agent grinding a codebase all night is not, and that cost is the same wherever it runs.
Two levers keep the inference line sane:
- Bring your own subscription. Claude Code runs on your Anthropic login and Codex on your ChatGPT login, so heavy agent work rides a flat subscription you already pay for instead of metered API billing. Hivra adds zero markup on AI usage either way.
- Tune the heartbeat. A 15 minute heartbeat is 96 wakeups a day. If the job is "check the inbox," 30 or 60 minutes usually loses nothing and halves or quarters the always-on token spend.
For your specific stack, the hosting cost calculator prices the DIY and managed routes side by side with your numbers.
The one-click path
Everything above is buildable by hand. If you would rather spend the weekend on what the agent does instead of what keeps it alive, Hivra provisions the whole stack in about 5 minutes: a private VM per agent, crash recovery, persistent workspace, and Telegram connect for the proactive channel.
The agents are the official, unmodified tools. Claude Code signs in with your own Anthropic account, Codex with your own ChatGPT account, and Hivra never sees those credentials or marks up your AI usage. The free tier launches one agent at $0 so you can test the loop end to end; it sleeps after 4 idle days, so for true 24/7 the Pro plan at $9.99/month is the fit. If the DIY route above sounds like a good weekend, take it. It works. The managed route exists for everyone who wants the agent working tonight.