Mac hosting guide

Keep Remote Mac Sessions Alive Between Logins

Run the job inside a named tmux session and hold a caffeinate assertion. The job then keeps running after the remote desktop connection drops. Any Figment plan includes SSH for re-attaching.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Start the job inside a named tmux session and hold a caffeinate power assertion. Then the job keeps running when your laptop closes or the connection drops, and you can re-attach later over SSH. The tmux behaviour below is from the tmux(1) manual, and LaunchAgent behaviour is from Apple's Creating launchd Jobs.

Why do my processes die when I disconnect?

Two things usually kill a long job. First, a terminal opened by a remote desktop client is attached to a pseudo-terminal (pty). When the client closes, the pty closes, and the kernel sends SIGHUP to the foreground process group, which ends the process unless it ignores the signal. Second, macOS can idle into sleep when nothing holds a power assertion, which suspends the network stack and stalls background jobs. Fix both and builds, test runs and data jobs outlast every disconnect.

How do I keep a job running with tmux?

Start a named session before the long job. tmux runs a server process that owns sessions independently of any client. Install it once if it is missing:

brew install tmux
tmux new-session -s build

Inside the session, run your build normally. To detach without killing it:

C-b d          # detach: session and its processes keep running

After reconnecting, re-attach:

tmux attach-session -t build
TaskCommand
New named sessiontmux new-session -s build
Detach, keep runningC-b d
List sessionstmux ls
Re-attach by nametmux attach-session -t build
Re-attach to most recenttmux attach
Kill a finished sessiontmux kill-session -t build
Renametmux rename-session -t old new
New window inside sessionC-b c
Split pane left/rightC-b %
Split pane top/bottomC-b "
Peek without attachingtmux capture-pane -t build -p | tail -20

Name sessions by job type plus a short date so tmux ls makes sense after a weekend away, for example release-20261110, tests-integration or data-etl.

How do I stop the Mac from sleeping mid-job?

Use caffeinate. It ships with macOS and takes an IOKit power-management assertion, the same mechanism Xcode uses when it shows "Preventing Sleep". Wrap a single job, and the assertion is released when the command exits:

caffeinate -i make all 2>&1 | tee build.log

Or hold one assertion for several jobs:

caffeinate -i &
echo "caffeinate PID: $!"

-i prevents idle sleep while letting the display dim. Add -d only if something needs the display on. -s prevents system sleep but only on AC power, so it matters on Mac mini and Mac Studio hardware, not on laptops running on battery.

How do I start caffeinate automatically?

Use a LaunchAgent. A LaunchAgent in ~/Library/LaunchAgents/ starts when your user session opens and restarts the program if it exits. Put this at ~/Library/LaunchAgents/com.figment.caffeinate.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.figment.caffeinate</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/caffeinate</string>
        <string>-i</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

Set permissions and load it without rebooting:

chmod 600 ~/Library/LaunchAgents/com.figment.caffeinate.plist
launchctl load  ~/Library/LaunchAgents/com.figment.caffeinate.plist
launchctl list | grep caffeinate     # a PID in the first column means it is running

To stop it:

launchctl unload ~/Library/LaunchAgents/com.figment.caffeinate.plist

Label, ProgramArguments, RunAtLoad and KeepAlive are the keys Apple documents for this pattern. man launchd.plist lists the others you may want, such as StandardOutPath, WorkingDirectory and EnvironmentVariables.

Which system settings back this up?

Add a system-level backstop on a Mac you use as a build host:

  1. Open System Settings → Energy Saver (desktop Macs) or Battery (portable Macs).
  2. Set Turn display off after to Never.
  3. Enable Prevent automatic sleeping when the display is off if it is shown.
  4. On Mac mini or Mac Studio, enable Start up automatically after a power failure so the host comes back ready to resume LaunchAgents.

These settings persist across reboots and pair with the LaunchAgent above. Settings shown on a Figment VM can differ from a physical Mac, so check what your plan's System Settings offers.

How do I check progress without staying connected?

Write the build output to a log inside the session, then detach:

# inside tmux
make all 2>&1 | tee ~/builds/release.log
# C-b d

Peek at the live pane without attaching:

tmux capture-pane -t build -p | tail -40

Or tail the log from any shell on the Mac, including an SSH session:

tail -f ~/builds/release.log

Every Figment plan includes SSH, so you can check progress without opening the remote desktop at all.

Where should a long-running tmux session live?

Any plan can host a tmux session. Use the Intel Mac VM ($0.15 an hour, $25 a month) for scripts, data jobs and Xcode 26.3 or earlier. Use the Apple Silicon Mac VM ($39 a month) for arm64-only binaries, Xcode 26.4 or later and visionOS. Billing runs until you stop the Mac in Figment, even when you are disconnected or macOS is shut down, so stop an hourly Mac when a long job is finished.

What else should I read?

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan