DocsOperatorsBackground jobs

Background jobs

rim-server runs these jobs inside its own process on a timer; there is no cron to set up. Each starts with the server and stops when it shuts down. A run that fails logs an error and the next run tries again. More than one server process on the same database each runs every job; the purges are idempotent, so a second run finds nothing left to do.

Job Interval Setting What it does
Presence and typing 30 seconds none Moves users without a heartbeat to away after 90 seconds and offline after 180, and drops stale typing indicators.
Webhook test sessions 30 seconds none Drops webhook test sessions past their expiry, and what they hold, from memory (bots.md, "Seeing what a service sends").
Pipeline evaluator on every event none Runs the workspace pipelines that match each event.
Notification digest 15 minutes RIM_NOTIFICATION_DIGEST_INTERVAL_SECS (at least 60) Emails due notification digests. Off when the email feature is disabled.
Notification and MLS retention hourly none Deletes notifications older than 90 days and the MLS rows the encryption retention rules let go.
Server-to-server upkeep every minute RIM_RELAY_RETENTION_DAYS (default 30) for the relay queue Deletes expired server-to-server nonces, relay queue items and DM requests past retention (one of a conversation this server hosts is cleared instead while its recipient is a member, docs/relay.md), outbox rows past their retention, old seen-request records and ended delegations; picks up a server key or franking key rotated by the CLI.
Revocation fan-out 5 seconds runs while server-to-server traffic is on Sends device revocations due for another attempt to the hosts holding the person.
Outbox writer and sender on every event runs while server-to-server traffic is on; RIM_S2S_PEER_DEAD_AFTER_HOURS (default 24) Turns events into signed envelopes and delivers each relay's outbox in order. Writes no row for a relay whose unacknowledged rows are at 100,000 or 2 GiB, or that is dead; tries a dead relay every 5 minutes.
Metrics sampler 30 seconds, first at boot runs when RIM_METRICS_ADDR is set Reads local account/activity totals, stored relay rows, the outbox, pending device delivery and pending migrations into gauges. Tracks success, failures and last-success time separately for each sample; the database pool is read on each scrape (docs/operations/metrics.md).
Audit retention daily, first a minute after boot RIM_AUDIT_RETENTION_DAYS; unset, the job does not run Exports and deletes command audit rows past retention (docs/operations/audit-retention.md).
Audit export retention daily, first a minute after boot RIM_AUDIT_EXPORT_RETENTION_DAYS; unset, the job does not run Deletes the audit export files written more than that many days ago, logs how many and adds them to rim_audit_exports_deleted_total (docs/operations/audit-retention.md).
Audit file retention daily, first a minute after boot RIM_AUDIT_LOG_RETENTION_DAYS (default 90) Deletes the daily audit files audit.<YYYY-MM-DD>.log whose day is further back than the retention, and logs how many (docs/operations/audit-retention.md).
Stale attachment cleanup hourly, first 5 minutes after boot none Marks attachment uploads still pending 5 minutes after they started as failed, so they stop counting as in progress. Logs the count and adds it to rim_attachments_cleaned_total. Also deletes the files and rows of attachments whose message was deleted (not those of a reported message, which stay for the report), up to 200 a run.
IP deny list 30 seconds, first loaded at boot none Reads the IP blocks in force, so a block or unblock made with rim_server ip applies within 30 seconds, and deletes expired blocks. A read that fails keeps the list it had.
Workspace state expiry hourly, first 5 minutes after boot none Deletes workspace state entries whose time to live ran out. Logs the count and adds it to rim_workspace_state_purged_total.
Session purge hourly, first 5 minutes after boot none; RIM_SESSION_TTL_DAYS (default 30) sets when a session expires Deletes the sessions that sign nobody in any more: revoked ones (sign-out, a revoked device, a block) and those past their expiry, which is set at sign-in and never extended. Logs the count and adds it to rim_sessions_purged_total.
Conversation invitation expiry hourly, first 5 minutes after boot none Deletes pending invitations to encrypted conversations not accepted within 30 days. Logs the count and adds it to rim_conversation_invites_expired_total.
Remote identity and peer pin purge hourly, first 5 minutes after boot none; the peers named in RIM_S2S_DENIED_PEERS, RIM_HOST_ALLOWED_RELAYS and RIM_DM_PARTNERS are kept Deletes cached identities of people on other servers fetched more than 30 days ago, except those of remote users held here, and adds the count to rim_remote_identities_purged_total. Forgets the active pins of other servers neither fetched nor sent a request for 90 days that nothing here refers to (a remote user's home relay or card, a delegation, a subscription, an outbox row, an inbound cursor, a queued envelope, a DM request, a revocation fan-out, a conversation's predecessor, a cached identity), keeping each one's key-log head so its next pin must extend it; writes an s2s.peer_forgotten audit line per server and adds the count to rim_peer_pins_forgotten_total. Forked and blocked pins stay.
WebSocket session recheck RIM_WS_SESSION_RECHECK_SECS (default 30), first one interval after boot RIM_WS_SESSION_RECHECK_SECS; 0 turns it off Reads the sessions of this process's open WebSocket connections, one query per 500 sessions, and closes with 4401 the connections whose session is revoked, expired or gone: those ended in another process, from the command line or in the database. A read that fails is logged and closes nothing.
Account purge hourly, first 5 minutes after boot RIM_ACCOUNT_DELETION_GRACE_DAYS (default 14, 0 to 30) sets when a requested deletion is due Purges the accounts whose deletion grace period ended, each in its own transaction, at most 100 a run: cancels their subscriptions at other servers, deletes what they own (their join requests included) and leaves a tombstone row. Join requests need no job: one past its 30 days is expired when it is read. Writes an account.purged audit line with the counts per account; an account whose purge fails is logged and tried again next run. rim_server account purge [--dry-run] runs it once.

Rendered from rim-server/docs/operations/background-jobs.md at 2dd12c8