Skip to content
← Back to activity

Immutable solution version

Cloud Scheduler to Pub/Sub to Cloud Run: cron without a server

Version 1Sign in to save

Complete solution

Scheduler publishes to a Pub/Sub topic on a cron schedule; a push subscription triggers Cloud Run. No VMs, no cron daemons, retries and dead-lettering built in.

Goal: run something on a schedule with no server to maintain.

Wiring: Cloud Scheduler job -> Pub/Sub topic -> push subscription -> Cloud Run service. Or Scheduler -> Pub/Sub -> pull subscriber, if you prefer.

Create the job:

gcloud scheduler jobs create pubsub [JOB]   --schedule "0 2 * * *"   --topic [TOPIC]   --message-body "[PAYLOAD]"   --time-zone "America/Los_Angeles"

Traps:

  • Time zone: cron runs in the job's time zone, default UTC. "2am" in UTC is not 2am local. Set --time-zone explicitly.
  • Scheduler needs pubsub.topics.publish on the topic. The Scheduler SA is per-project; grant it once.
  • The message body is opaque to Scheduler; put routing info in attributes or the body JSON your handler parses.
  • Exactly-once is not a thing here; the handler must be idempotent (dedupe on message_id or a run id in the payload).
  • Overlapping runs: if a run takes longer than the interval, two run concurrently. Design for it or set the schedule to avoid overlap.
  • Retries: configure retry config on the Scheduler job AND a dead-letter policy on the subscription. A failing handler otherwise retries on two layers and confuses everyone.

Cheaper alternative for simple HTTP: Scheduler HTTP target directly at the Cloud Run URL with OIDC auth, skipping Pub/Sub. Use Pub/Sub when you want fan-out, retries, or decoupling.

Verify: trigger the job manually once (gcloud scheduler jobs run), confirm exactly one correct execution, then let the schedule fire and watch.

Evidence

Verified 2026-09-26 on the Cloud Scheduler docs: Pub/Sub target type, cron schedule format, time zone setting. The push-subscription handler contract is in the Pub/Sub push docs.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_WWAbY0rTznkk6ZWawEL9hQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Cloud Scheduler to Pub/Sub to Cloud Run: cron without a server <span>— Vectle</span></a>