Execute jobs on a schedule

This page describes how to execute Cloud Run jobs on a schedule usingCloud Scheduler.

Required roles

To get the permissions that you need for the operations described on this page,ask your administrator to grant you the IAM roles on yourCloud Run job:

  • Cloud Scheduler Admin(roles/cloudscheduler.admin), or a custom role with thecloudscheduler.jobs.create permission.
  • Cloud Run Invoker (roles/run.invoker)to execute jobs using the Google Cloud CLI, orCloud Run Developer(roles/run.developer) to execute jobs using the Google Cloud console.

For a list of IAM roles and permissions that are associated withCloud Run, seeCloud Run IAM rolesandCloud Run IAM permissions.If your Cloud Run job interfaces withGoogle Cloud APIs, such as Cloud Client Libraries, see theservice identity configuration guide.For more information about granting roles, seedeployment permissionsandmanage access.

Before you begin

Create a Cloud Run job if you have not createdone yet.

Configure a Cloud Run job to execute on a schedule

To execute a Cloud Run job on a schedule:

Console

  1. Go to Cloud Run jobs

  2. Click the job you want to execute on a schedule.

  3. Click theTriggers tab.

  4. ClickAdd Scheduler Trigger.

  5. If you haven't yet enabled the Cloud Scheduler API for your project, youare prompted to do so in the far right panel: clickEnable API.

  6. Fill out the Cloud Scheduler job form

    image

  7. UnderDefine a schedule:

    1. Give your Cloud Scheduler job a name.

    2. Select a region for your Cloud Scheduler job. It does not need tomatch the region used for the Cloud Run job.

    3. Specify thefrequency for your job execution, using theunix-cron format, for example,0 12 * * *

    4. Select your timezone.

  8. ClickContinue.

  9. In theService Account menu, select a service accountthat has the permission to invoke the current Cloud Run service.

  10. ClickCreate to create the Cloud Scheduler job that will executethe Cloud Run job at the specified frequency.

Command line

  1. Make sure youcreate a Cloud Run job first.

  2. Run the command:

    gcloudschedulerjobscreatehttpSCHEDULER_JOB_NAME\--locationSCHEDULER_REGION\--schedule="SCHEDULE"\--uri="https://run.googleapis.com/v2/projects/PROJECT-ID/locations/CLOUD_RUN_REGION/jobs/JOB-NAME:run"\--http-methodPOST\--oauth-service-account-emailPROJECT-NUMBER-compute@developer.gserviceaccount.com

    Replace

    • SCHEDULER_JOB_NAME with the name you want to give your scheduler job.
    • SCHEDULER_REGION with a region supported byCloud Scheduler, for example,europe-west2.
    • CLOUD_RUN_REGION with the region for your Cloud Runjob. For example,europe-west1.
    • SCHEDULE with the necessary frequency, for example0 12 * * *.
    • PROJECT-ID with your project ID.
    • PROJECT-NUMBER with your project number.
    • JOB-NAME with your Cloud Run job.

Terraform

To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.

Add the following to agoogle_cloud_run_v2_job resource in your Terraform configuration:
resource"google_cloud_scheduler_job""job"{provider=google-betaname="schedule-job"description="test http job"schedule="*/8 * * * *"attempt_deadline="320s"region="us-central1"project=data.google_project.project.project_idretry_config{retry_count=3}http_target{http_method="POST"uri="https://${google_cloud_run_v2_job.default.location}-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/${data.google_project.project.number}/jobs/${google_cloud_run_v2_job.default.name}:run"oauth_token{service_account_email=google_service_account.cloud_run_invoker_sa.email}}depends_on=[resource.google_project_service.cloudscheduler_api,resource.google_cloud_run_v2_job.default,resource.google_cloud_run_v2_job_iam_binding.binding]}

Cloud Scheduler will execute the Cloud Run job at the specifiedfrequency.

Schedule your job inside a VPC Service Controls perimeter

If your Google Cloud project is inside a VPC Service Controls perimeter in aVirtual Private Cloud network, the Cloud Scheduler integration withVPC Service Controls supports Cloud Run jobs as a target usingthe following URI format:

https://run.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobs/JOB_NAME:run

Replace the following:

  • PROJECT_ID: the Google Cloud project ID.
  • REGION: the Google Cloud region of the job.
  • JOB_NAME: the name of the Cloud Runjob.

For more information on configuring VPC Service Controls forCloud Run, seeUsing VPC Service Controls (VPC SC).For more information on using Cloud Scheduler with VPC Service Controls,seeSecure cron jobs with VPC Service Controls.

What's next

After you use this feature, you can do the following:

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.