# Cron and the scheduler

> How publishing and background syncs run, and how to drive them with an external cron on serverless or multi-instance deployments.

URL: https://heyorbit.tech/docs/self-hosting/cron-scheduler
Last updated: 2026-11-19

Self-hosting and deployment · [Documentation](https://heyorbit.tech/docs)

## What a tick does

Each tick does two things:

1. **Publishing:** posts that are due are published, up to 25 per tick, along with failed accounts whose automatic retry is due. A failed account is retried up to three times, a few minutes apart, when the error is temporary.
2. **Background syncs**, every MAINTENANCE_EVERY_MINUTES minutes (default 30, minimum 5): analytics and inbox sync, inbox tagging and alert digests, token refresh, scheduled reports, account and add-on renewals, "notify me" messages for newly available platforms, and renewal reminders 3 days before each rupee renewal.

Ticks are cheap when there's nothing to do. HeyOrbit caches when it next has publishing work and only asks the database when that moment is near, so a scale-to-zero database (such as Neon) can sleep between posts. The cached time is refreshed whenever a post changes, after every publishing run, and at least every 30 minutes. A lock stops two ticks overlapping on one instance.

## In-process timer

With INPROCESS_SCHEDULER=true (the default), a long-running server ticks every 30 seconds. The timer starts the first time someone opens the dashboard after the server boots. It never starts on Vercel, AWS Lambda or Netlify, which have no long-running process. Fine for a single Docker container or VM; add an external cron as well if you want publishing guaranteed right after a restart.

## External cron

For serverless platforms, several instances, or when you want the schedule in your own tooling:

1. Set INPROCESS_SCHEDULER=false.
2. Set CRON_SECRET to a long random string.
3. Call the tick endpoint every minute:

~~~bash
* * * * * curl -fsS -X POST https://social.example.com/api/cron/tick \
  -H "Authorization: Bearer $CRON_SECRET" > /dev/null
~~~

On Vercel, vercel.json already schedules /api/cron/tick every minute, and Vercel sends CRON_SECRET as the bearer token. GitHub Actions, Cloud Scheduler or any HTTP cron also work.

The endpoint answers { "ok": true, "data": { "published": 3, "jobs": { … }, "nextWakeAt": "…", "durationMs": 412 } }. Without the secret it answers 401; a signed-in workspace Owner may also call it from the browser. A call that overlaps a running tick returns { "skipped": true }.

| Endpoint | What it runs |
|---|---|
| /api/cron/tick | Publishing when due, and background syncs when their interval has passed |
| /api/cron/tick?force=1 | Everything, now |
| /api/cron/sync | Background syncs only, now |

With a per-minute cron, posts go out within about a minute of their time.

## Monitoring

- /api/health returns 200 with the database status and latency, the version, the scheduler state (in-process or not, when background syncs last ran), whether AI is configured and which platforms are configured. It returns 503 when the database is unreachable.
- Tick responses include durationMs; alert if ticks get slow.
- Failed posts notify their authors in the app, and by email when the workspace has email notifications on.

## Time zones

The scheduler compares exact moments in time; workspace timezones only affect how times are shown and entered ([timezones](https://heyorbit.tech/docs/getting-started/timezones)). The server's own TZ setting doesn't matter; keep it UTC.
