Keep an audit trail with three layers: launchd captures stdout and stderr from the moment the process starts, a wrapper script writes a timestamped JSON run receipt for every run, and SHA256 hashes tie each input and output file to that receipt. Without a receipt, you cannot prove what a scheduled job touched, when it finished, or whether the file your downstream system received is the file your script produced. A single scheduled agent runs well on a Figment Intel Mac VM at $25 a month.
Which Figment plan matches my agent?
For one scheduled agent that calls APIs, transforms JSON and pushes artifacts to object storage, the Intel Mac VM is the right start. It has 4 shared vCPUs, 4GB of RAM and an 80GB SSD on macOS Sequoia, at $25 a month, $2 a day or $0.15 an hour. It runs macOS, so launchd, launchctl, shasum, jq and the shortcuts CLI work as documented. You get SSH, remote desktop and administrator access to your own VM.
| Workload | Plan | Price |
|---|---|---|
| One agent, scripted automation, no arm64-only tools | Intel Mac VM | $25 a month |
| arm64-only binaries, Xcode 26.4 or later, visionOS tooling | Apple Silicon Mac VM | $39 a month |
| Concurrent agents or heavy jobs on a whole Mac, or audit data you want on a Mac no one else shares | Dedicated M4 Pro 48 GB (M4 Pro, 48GB, 512GB) | $349 a month |
VM vCPUs are shared, not reserved cores. The audit tooling itself (hashing, JSON, logs) is light.
What must the receipt prove?
Decide this before you write code, and pin the same fields on every job. That lets you query the archive with jq and hand it to an auditor without custom tooling.
| Field | What to record |
|---|---|
run_id | ISO timestamp plus a random hex suffix, unique per invocation |
started_at / finished_at | UTC ISO 8601 |
inputs | Name and SHA256 of each input file or hashed parameter value |
outputs | Name, absolute path, byte count, SHA256 |
exit_code | Integer, written even when the job step fails |
log_path | Absolute path to the stdout and stderr log for this run |
Record only the environment variables you need to reproduce the run. Never write a full environment dump to disk, because it routinely contains API tokens, signing secrets and session cookies. Record the names of the required variables and let your secret manager supply values at job start.
What does the JSON run receipt look like?
Write one file per run, at the end, whether the job succeeded or failed.
{
"schema": "run-receipt/v1",
"run_id": "2026-11-10T14-32-01Z-a3f8b2",
"job_label": "com.example.data-sync",
"host": "figment-mac-01",
"started_at": "2026-11-10T14:32:01Z",
"finished_at": "2026-11-10T14:32:47Z",
"exit_code": 0,
"inputs": [
{ "name": "FEED_URL", "sha256": "e3b0c44298fc1c149afbf4c8996fb924..." }
],
"outputs": [
{
"name": "report.json",
"path": "/Users/agent/jobs/a3f8b2/report.json",
"bytes": 14228,
"sha256": "9f86d081884c7d659a2feaa0c55ad015..."
}
],
"log_path": "/Users/agent/Library/Logs/example/data-sync-2026-11-10T14-32-01Z-a3f8b2.log",
"env_snapshot": { "LANG": "en_US.UTF-8" }
}
If your job calls Apple's Shortcuts CLI, shortcuts exits 0 on success and 1 on error, per Apple's command-line reference for Shortcuts. Capture that exit code into exit_code and do not infer success from output.
How do I make launchd capture logs before my script starts?
Redirect stdout and stderr in the LaunchAgent plist. This happens from the moment the process is spawned, so early crashes still leave a trace. Place the file at ~/Library/LaunchAgents/com.example.data-sync.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.example.data-sync</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/data-sync-wrapper.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key> <integer>3</integer>
<key>Minute</key> <integer>0</integer>
</dict>
<key>StandardOutPath</key>
<string>/Users/agent/Library/Logs/example/launchd-out.log</string>
<key>StandardErrorPath</key>
<string>/Users/agent/Library/Logs/example/launchd-err.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin</string>
</dict>
</dict>
</plist>
Label, ProgramArguments, KeepAlive, StartCalendarInterval, StandardOutPath and StandardErrorPath are documented in Apple's Creating Launchd Jobs reference, which also points to the launchd.plist(5) man page for the authoritative key list. On current macOS releases, load the agent with launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.data-sync.plist. The older launchctl load form still works. Check each key's behavior on the macOS version installed on your Mac, including what happens to stdout when StandardOutPath is omitted.
How does the wrapper script write the receipt?
It creates a unique work directory, redirects its own logs, runs the job, hashes the output and writes the receipt. set -euo pipefail stops early on unexpected errors. The explicit || { EXIT_CODE=$?; ... } around the job step keeps the real exit code, so the receipt reflects what happened even on failure.
#!/usr/bin/env bash
set -euo pipefail
JOB_LABEL="com.example.data-sync"
STARTED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # ISO 8601 for receipt
RUN_ID_TS=$(date -u +"%Y-%m-%dT%H-%M-%SZ") # filesystem-safe
RUN_ID="${RUN_ID_TS}-$(openssl rand -hex 3)"
WORK_DIR="${HOME}/jobs/${RUN_ID}"
LOG_DIR="${HOME}/Library/Logs/example"
LOG_FILE="${LOG_DIR}/${JOB_LABEL}-${RUN_ID}.log"
RECEIPT="${WORK_DIR}/receipt.json"
EXIT_CODE=0
umask 077
mkdir -p "${WORK_DIR}" "${LOG_DIR}"
exec >> "${LOG_FILE}" 2>&1 # per-run log; launchd plist catches early crashes
echo "[${STARTED_AT}] START ${JOB_LABEL} run_id=${RUN_ID}"
# ── your job logic ────────────────────────────────────────────────
OUTPUT="${WORK_DIR}/report.json"
curl --fail --silent --show-error \
--header "Authorization: Bearer ${API_TOKEN}" \
"${FEED_URL}" \
--output "${OUTPUT}" \
|| { EXIT_CODE=$?; echo "[$(date -u +%T)] fetch failed exit=${EXIT_CODE}"; }
# ──────────────────────────────────────────────────────────────────
FINISHED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
OUTPUT_SHA=""
OUTPUT_BYTES=0
if [[ -f "${OUTPUT}" ]]; then
OUTPUT_SHA=$(shasum -a 256 "${OUTPUT}" | awk '{print $1}')
OUTPUT_BYTES=$(stat -f "%z" "${OUTPUT}")
fi
cat > "${RECEIPT}" <<JSON
{
"schema": "run-receipt/v1",
"run_id": "${RUN_ID}",
"job_label": "${JOB_LABEL}",
"started_at": "${STARTED_AT}",
"finished_at": "${FINISHED_AT}",
"exit_code": ${EXIT_CODE},
"outputs": [
{
"name": "report.json",
"path": "${OUTPUT}",
"bytes": ${OUTPUT_BYTES},
"sha256": "${OUTPUT_SHA}"
}
],
"log_path": "${LOG_FILE}"
}
JSON
echo "[$(date -u +%T)] receipt written: ${RECEIPT}"
exit "${EXIT_CODE}"
Pass API_TOKEN and FEED_URL through the launchd EnvironmentVariables dict or your CI secret manager. Do not put secret literals on the command line, where they land in the process listing and shell history.
How do I check a run and replay it?
After each scheduled fire, launchctl print gui/$(id -u)/com.example.data-sync shows the last exit status and run count. Compare it with the latest receipt. If the receipt is missing, the wrapper crashed before the write step, and the launchd StandardOutPath log holds the trace.
Add a short verification job that runs right after each sync:
#!/usr/bin/env bash
set -euo pipefail
LATEST=$(ls -t ~/jobs/*/receipt.json 2>/dev/null | head -1)
[[ -n "${LATEST}" ]] || { echo "ERROR: no receipt found"; exit 1; }
EC=$(jq '.exit_code' "${LATEST}")
[[ "${EC}" -eq 0 ]] || { echo "ERROR: last run exited ${EC}"; exit 1; }
echo "OK run_id=$(jq -r '.run_id' "${LATEST}") finished=$(jq -r '.finished_at' "${LATEST}")"
For replay integrity, re-fetch the same input from your source of record, rehash it and compare it with the inputs field in the receipt. A mismatch means the upstream feed changed after your run finished, which is the question an auditor will ask.
Rotate work directories too. A small second LaunchAgent that deletes receipts and logs older than 30 days keeps the VM's 80GB disk (OS included) from filling unnoticed. For a nightly agent that writes a few hundred kilobytes per run, a month of receipts, logs and outputs is well under 1GB.
How do I keep the audit trail safe from loss?
Copy receipts off the Mac if you need them for compliance. Figment does not back up your Mac, so ship receipts to your own archive. After you stop a Mac, access stops. A stopped Mac is kept free for 24 hours. After that, storage costs a quarter of the plan's daily price for each day, until you delete the Mac.
How do I move an existing agent onto a hosted Mac?
Copy the wrapper script and plist to the Mac over SSH, place the plist under ~/Library/LaunchAgents/, bootstrap it, and trigger a test run with launchctl kickstart gui/$(id -u)/com.example.data-sync. Confirm a receipt appears at ~/jobs/*/receipt.json and that its exit_code is 0 before you rely on the schedule. Pick a machine from the Mac hosting plans.
Related guides:
TCC permissions for Mac agents · App crash recovery on a hosted Mac · GitHub Actions self-hosted runner on Mac