Mac hosting guide

Resume Hosted Mac Jobs After a Network Failure

Supervise the job with launchd KeepAlive, keep a state file in an idempotent wrapper, and reconcile partial side effects before retrying. A Figment Intel Mac VM ($25 a month) runs script-only agents.

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.

To resume a Mac job after a network failure, supervise it with launchd KeepAlive, have a wrapper script record the job's state in a file, and reconcile any side effects from a partial run before you retry. A script-only agent (Python, Node.js, curl, shell) that calls external APIs runs on a Figment Intel Mac VM at $25 a month. Jobs that need Apple silicon go on an Apple Silicon Mac VM at $39 a month.

Which Figment Mac plan fits the job?

Pick the plan by what the job executes. VM vCPUs are shared, not reserved cores. Prices are USD before tax.

RequirementPlanPrice
CLI tools, Python, Node.js, curl, no arm64-only binariesIntel Mac VM, 4 vCPUs, 4GB, 80GB$25 a month, $2 a day
arm64-only binaries, Xcode 26.4 or later, Apple silicon appsApple Silicon Mac VM, 4 shared vCPUs, 4GB, 65GB$39 a month, $6 a day
Heavy local I/O or concurrency, or a Mac that is only yoursDedicated M4 Pro 48 GB, M4 Pro, 48GB, 512GB$349 a month ($299 on a 12-month term)

A standard script that polls an API, transforms JSON or pushes artifacts runs on the Intel VM without issue. It runs macOS Sequoia, and Apple lists Xcode up to 26.3 for that version. Arm64-only binaries and visionOS need an Apple silicon plan.

The Intel Mac VM and the Dedicated M4 Pro include SSH, encrypted remote desktop and browser access; the Apple Silicon Mac VM has the browser desktop and SSH. Outbound connections from the Mac, such as CI agents, API calls and webhooks, work normally. Run commands over SSH or in a remote desktop terminal, or use an outbound CI agent that reaches back to your orchestrator.

What should I define before I write recovery code?

Define four things:

Trigger
a launchd schedule, an inbound webhook delivered through an outbound agent, a file watch, or a shortcuts run call from a remote orchestrator.
State boundary
which side effects are write-once (an API debit, a sent message) and which are safe to retry with the same idempotency key.
Credentials
stored in your CI secret manager and injected as environment variables at run time. Do not export the whole environment to disk, because it can contain unrelated secrets.
Idempotency key
a unique token (run ID plus UTC timestamp) written at job start and queryable from the downstream API at resume.

The macOS Shortcuts CLI lets a remote orchestrator fire a named shortcut. Per Apple's Run shortcuts from the command line, shortcuts run "ProcessBatch" --input-path /data/batch.json returns 0 on success and 1 on failure, which a wrapper can capture before it writes a state flag.

How do I restart the job when the network returns?

Use a shell wrapper that tracks state in a file, and let launchd supervise the wrapper.

#!/usr/bin/env bash
# /usr/local/bin/run-agent-job.sh
# Example — adapt the shortcut name, API URL and paths to your project.
set -euo pipefail

STATE_DIR="$HOME/agent"
STATE_FILE="$STATE_DIR/job.state"
LOCK_DIR="$STATE_DIR/job.lock.d"
mkdir -p "$STATE_DIR"

# Prevent concurrent reruns (mkdir is atomic)
if ! mkdir "$LOCK_DIR" 2>/dev/null; then
  echo "Job already running" >&2; exit 1
fi
trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT

# Reconcile any prior partial run
if [[ -f "$STATE_FILE" ]]; then
  prior=$(cat "$STATE_FILE")
  if [[ "$prior" != "COMPLETE" ]]; then
    echo "Prior run ended at: $prior — running reconciliation" >&2
    /usr/local/bin/reconcile-job.sh "$prior" || exit 1
  fi
fi

echo "STARTED_$(date -u +%Y%m%dT%H%M%SZ)" > "$STATE_FILE"

# Confirm the target API is reachable before proceeding
curl -sf --max-time 10 https://api.example.com/health \
  || { echo "API not reachable yet" >&2; exit 1; }

# Main job
shortcuts run "ProcessBatch" --input-path /data/batch.json
echo "COMPLETE" > "$STATE_FILE"

Save this plist as ~/Library/LaunchAgents/com.yourteam.agentjob.plist and load it with launchctl load ~/Library/LaunchAgents/com.yourteam.agentjob.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.yourteam.agentjob</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/bin/run-agent-job.sh</string>
  </array>
  <key>KeepAlive</key>
  <dict>
    <key>NetworkState</key><true/>
    <key>SuccessfulExit</key><false/>
  </dict>
  <key>ThrottleInterval</key><integer>60</integer>
  <key>StandardOutPath</key><string>/tmp/agentjob.log</string>
  <key>StandardErrorPath</key><string>/tmp/agentjob.err</string>
</dict>
</plist>

Per the launchd.plist reference on launchd.info, KeepAlive with NetworkState: true starts the job while any network interface is available, and SuccessfulExit: false keeps relaunching until the wrapper exits 0. ThrottleInterval: 60 enforces a 60-second pause between invocations and prevents a tight crash loop. For rate-limited downstream APIs, raise it to 300 seconds.

launchd treats the network as available once any interface holds an IP address. That does not prove internet reachability or that your API is healthy, so the curl probe inside the wrapper closes that gap.

What do I do after an unexpected exit?

Walk this tree to pick the recovery action:

Job exited with non-zero status
│
├── STATE_FILE = STARTED_<timestamp>   ← partial run
│   ├── Are all side effects idempotent for this run ID?
│   │   ├── YES → let launchd restart; wrapper retries safely
│   │   └── NO  → run reconcile-job.sh <timestamp>
│   │             query the API for records already committed
│   │             de-duplicate, then allow restart
│   └── Lock dir stale (process gone, lock dir present)?
│       └── rmdir "$LOCK_DIR"; run reconciliation; restart
│
├── STATE_FILE = COMPLETE              ← clean exit
│   └── Check upstream trigger; no reconciliation needed
│
└── STATE_FILE missing                 ← job never started
    └── Restart is clean; no reconciliation needed

Side-effect reconciliation checklist:

  • Query the downstream API for records tagged with the current idempotency key.
  • Delete or skip duplicates before resubmitting.
  • Rotate or void any one-time tokens consumed during the failed run.
  • Append a log entry: timestamp, prior state, reconciliation action, outcome.

How do I confirm the job recovered?

Run four checks after the network returns:

  1. tail -50 /tmp/agentjob.log. Look for a gap of at least ThrottleInterval seconds between the failed entry and the restart. A shorter gap points to a non-network bug.
  2. launchctl list | grep agentjob. A numeric PID means the job is active, and the exit-status column holds the last exit code.
  3. cat ~/agent/job.state. COMPLETE means the last full run succeeded. A STARTED_ timestamp that persists across two restarts points to a deterministic failure, not a transient drop.
  4. curl -sf https://api.example.com/health && echo ok. This separates a machine-level network issue from an upstream API outage.

How long should the retry delay be?

Match it to the downstream rate limit. A quota of 60 requests per minute should not be retried every 10 seconds during recovery. A ThrottleInterval of 60 to 120 seconds stays inside the window and still restores the job quickly.

What does it cost to run this?

A job that runs for a short test costs little on a daily plan: $2 a day on the Intel VM, $6 on the Apple Silicon VM. A job that runs continuously fits a monthly plan ($25 or $39), which renews on the payment date until you cancel. Shutting down macOS does not stop billing. Figment does not monitor your job. You own alerting on stalled runs, and the state file and launchctl list checks above are the place to start.

How do I start or migrate the workload?

Pick a plan on Figment Mac hosting, copy the plist and wrapper into place, inject credentials from your CI secret manager, and load the agent with launchctl load. Test the recovery path by disconnecting the Mac's network on purpose or by blocking the API host, and confirm the job restarts and reconciles.

Related guides:

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