How to Set Up Cron Jobs on Google Cloud (Cloud Scheduler)
Learn how to schedule cron jobs on Google Cloud using Cloud Scheduler. Covers targeting Cloud Functions, Cloud Run, Pub/Sub, and HTTP endpoints.
Prerequisites
- Google Cloud account
- gcloud CLI configured
- A target service (Cloud Function, Cloud Run, or HTTP endpoint)
In this guide
What Is Cloud Scheduler?
Google Cloud Scheduler is a fully managed cron service. It triggers targets on a schedule — Cloud Functions, Cloud Run services, Pub/Sub topics, or arbitrary HTTP endpoints.
It uses standard Unix cron syntax (5 fields) and supports IANA timezone names. You get 3 free jobs per month, then $0.10/job/month after that.
Quick Start with gcloud CLI
Create a job targeting an HTTP endpoint:
gcloud scheduler jobs create http my-job \
--schedule="0 9 * * 1-5" \
--uri="https://my-app.run.app/api/daily-task" \
--http-method=POST \
--time-zone="America/New_York" \
--location=us-central1Trigger a Cloud Function:
gcloud scheduler jobs create http my-function-job \
--schedule="*/5 * * * *" \
--uri="https://us-central1-my-project.cloudfunctions.net/myFunction" \
--http-method=POST \
--oidc-service-account-email=scheduler-sa@my-project.iam.gserviceaccount.comPublish to Pub/Sub:
gcloud scheduler jobs create pubsub my-pubsub-job \
--schedule="0 */6 * * *" \
--topic=my-topic \
--message-body='{"action": "cleanup"}' \
--time-zone="UTC"Common Cron Expressions
Standard 5-field Unix cron format:
*/5 * * * *— Every 5 minutes0 * * * *— Every hour0 0 * * *— Daily at midnight0 9 * * 1-5— Weekdays at 9 AM0 0 1 * *— First day of every month0 0 * * 0— Every Sunday at midnight
Cloud Scheduler also supports timezone-aware scheduling — set the timezone when creating the job.
Every weekday at 9:00 AM
Next runs (UTC):
Mon, May 18, 2026 09:00
Tue, May 19, 2026 09:00
Wed, May 20, 2026 09:00
Targeting Different Services
Cloud Scheduler can target three types of endpoints:
HTTP (Cloud Functions, Cloud Run, any URL):
gcloud scheduler jobs create http job-name \
--schedule="0 9 * * *" \
--uri="https://my-service.run.app/cron" \
--http-method=POST \
--headers="Content-Type=application/json" \
--body='{"task":"cleanup"}'Pub/Sub (for decoupled architectures):
gcloud scheduler jobs create pubsub job-name \
--schedule="0 * * * *" \
--topic=my-topic \
--message-body='trigger'App Engine HTTP:
gcloud scheduler jobs create app-engine job-name \
--schedule="0 0 * * *" \
--service=my-service \
--relative-url=/cron/dailyRetry Configuration
Cloud Scheduler retries failed jobs automatically. Configure retry behavior:
gcloud scheduler jobs create http my-job \
--schedule="0 9 * * *" \
--uri="https://my-app.run.app/task" \
--attempt-deadline=300s \
--max-retry-attempts=3 \
--min-backoff=5s \
--max-backoff=1h \
--max-doublings=5- attempt-deadline — Max time to wait for a response (default: 30 minutes)
- max-retry-attempts — Number of retries (0 = no retries, -1 = unlimited)
- Backoff — Exponential backoff between retries
Managing Jobs
# List all jobs
gcloud scheduler jobs list --location=us-central1
# Describe a job
gcloud scheduler jobs describe my-job --location=us-central1
# Run a job immediately (for testing)
gcloud scheduler jobs run my-job --location=us-central1
# Pause a job
gcloud scheduler jobs pause my-job --location=us-central1
# Resume a paused job
gcloud scheduler jobs resume my-job --location=us-central1
# Update schedule
gcloud scheduler jobs update http my-job \
--schedule="0 10 * * *" --location=us-central1
# Delete a job
gcloud scheduler jobs delete my-job --location=us-central1Production Tips
Authentication: Use OIDC tokens for Cloud Functions/Cloud Run targets:
gcloud scheduler jobs create http my-job \
--schedule="0 * * * *" \
--uri="https://my-service.run.app/cron" \
--oidc-service-account-email=scheduler@project.iam.gserviceaccount.comMonitoring: Cloud Scheduler logs all executions to Cloud Logging. Set up alerts for job failures:
gcloud logging read 'resource.type="cloud_scheduler_job" AND severity>=ERROR' --limit=10Cost: 3 free jobs/month per billing account. Additional jobs are $0.10/job/month. Execution is free — you only pay for the target service (Cloud Functions, Cloud Run, etc.).