Cron & Scripting
Schedule recurring runs, pipe to scripts, store output.
Prerequisites
- API key login (cron jobs are non-interactive — OAuth won't work)
Use an API key in cron
# Either store via betterness auth login --key bk_..., or pass per-call:
0 6 * * * betterness workflow daily-brief --json --api-key bk_your_key > /tmp/brief.json
Daily brief at 6 AM, posted to a webhook
# crontab -e
0 6 * * * betterness workflow daily-brief --json | curl -X POST -d @- https://your-webhook.com/health
Email yourself out-of-range biomarkers
betterness biomarkers search --range OUT_OF_RANGE --json \
| jq -r '.[] | "\(.name): \(.value) \(.unit) (range \(.minRange)-\(.maxRange))"' \
| mail -s "Biomarkers out of range" you@example.com
Save daily activity to S3
DATE=$(date +%Y-%m-%d)
betterness activity get --from "$DATE" --to "$DATE" --timezone America/Denver --json \
| aws s3 cp - "s3://my-bucket/activity/$DATE.json"
Detect significant biomarker changes
betterness biomarkers search --json \
| jq '.[] | select((.value > (.maxRange // 9999)) or (.value < (.minRange // -9999))) | .name'
Use --quiet for exit-code-only checks
if betterness auth whoami --quiet; then
betterness workflow daily-brief
else
echo "Re-auth needed" >&2
exit 1
fi
Tips
- Always include
--timezonein cron — the cron host may be UTC - Capture
stderrseparately — failures go there - Rate limits: 100/day free, 5,000/day builder. Daily cron well within either tier.
- If you run on a server, store the API key in a secret manager and inject as
BETTERNESS_API_KEY

