This page describes how to execute Cloud Run jobs on a schedule using Cloud Scheduler.
Before you begin
Use a Cloud Scheduler job to execute a Cloud Run job on a schedule
To create a Cloud Scheduler job that is configured to executes a Cloud Run job on a schedule:
Visit the Cloud Scheduler page in the console:
Click Create a job.
Under Define a schedule:
Give your job a name.
Select a region for your Cloud Scheduler job. It does not need to match the region used for the Cloud Run job.
Specify the frequency for your job, using the unix-cron format, for example,
0 12 * * *
Select your timezone.
In the Target type field,
select HTTP from the dropdown menu.
For URL, enter:
- REGION with the region for the your Cloud Run job.
- PROJECT-ID with your Google Cloud project ID, for
- JOB-NAME with the name of your Cloud Run job.
For HTTP method, select POST. Leave HTTP headers and Body blank.
Click Auth header
Select Add OAuth token.
Select a service account that has the Cloud Run Invoker role on the Cloud Run job to be triggered, or the Cloud Run Admin, Editor or Owner roles on the project. Note that for a test project, the default compute service account (
PROJECT-NUMBERfirstname.lastname@example.org) typically has sufficient permissions. Refer to Access control with IAM for more information.
Leave the scope field blank.
Set any desired optional settings.
Make sure you create a Cloud Run job first.
Run the command:
gcloud scheduler jobs create http SCHEDULER_JOB_NAME \ --location SCHEDULER_REGION \ --schedule="SCHEDULE" \ --uri="https://CLOUD_RUN_REGION-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/PROJECT-ID/jobs/JOB-NAME:run" \ --http-method POST \ --oauth-service-account-email PROJECT-NUMBERemail@example.com
- SCHEDULER_JOB_NAME with the name you want to give your scheduler job.
- SCHEDULER_REGION with a region supported by
Cloud Scheduler, for example,
- CLOUD_RUN_REGION with the region for the your Cloud Run
job. For preview, use
- SCHEDULE with the desired frequency, for example
0 12 * * *
- PROJECT-ID with your project ID.
- PROJECT-NUMBER with your project number.
- JOB-NAME with your Cloud Run job.
Cloud Scheduler now runs the Cloud Run job at the specified frequency.
After you use this feature, you can do the following:
- View job logs
- Monitor job performances
- Create a job
- Execute a job
- Manage jobs