Manage jobs

This page describes how to manage jobs. To create a job, see create jobs. To execute a job, see Execute jobs.

Required roles

To get the permissions that you need to manage Cloud Run jobs, ask your administrator to grant you the Cloud Run Developer (roles/run.developer) IAM role on your Cloud Run job.

For a list of IAM roles and permissions that are associated with Cloud Run, see Cloud Run IAM roles and Cloud Run IAM permissions. If your Cloud Run job interfaces with Google Cloud APIs, such as Cloud Client Libraries, see the service identity configuration guide. For more information about granting roles, see deployment permissions and manage access.

View jobs in your project

You can view a list of the jobs in your project using one of the following approaches:

Console

To view jobs:

  1. Go to the Cloud Run jobs page.

  2. Optionally, filter the job by one of the criteria in the dropdown menu, such as job name, execution time, region, and so on.

gcloud

  1. To list all jobs in your project:

    gcloud run jobs list
  2. To filter jobs by region:

    gcloud run jobs list --region REGION

    Replace REGION with the name of the region you are filtering on, for example us-central1.

For other ways to refine the returned list, including the use of filters, see jobs list.

Client libraries

To view jobs in your project from code:

REST API

To view the list of jobs in your project, send a GET HTTP request to the Cloud Run Admin API jobs endpoint.

For example, using curl:

curl -H "Content-Type: application/json" \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -X GET \
  -d '' \
  https://run.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobs

Replace:

  • ACCESS_TOKEN with a valid access token for an account that has the IAM permissions to view jobs. For example, if you are logged into gcloud, you can retrieve an access token using gcloud auth print-access-token. From within a Cloud Run container instance, you can retrieve an access token using the container instance metadata server.
  • REGION with the Google Cloud region of the job.
  • PROJECT-ID with the Google Cloud project ID.

View job details

Use the gcloud command line to see more details about a job.

Console

To view details for a specific job execution:

  1. Go to the Cloud Run jobs page

  2. Locate the job you are interested in.

  3. Click the job to display the job details page.

  4. Note the History, Metrics, Logs, Triggers and YAML tabs.

    • The History tab shows information about the tasks in the job execution.
    • Logs shows the logs information.
    • Metrics shows information about the job executions.
    • YAML shows the configuration of the job in YAML format.

gcloud

To view details about a job:

Use the command:

gcloud run jobs describe  JOB_NAME

Replace JOB_NAME with the name of the job.

Client libraries

To view details about a job from code:

REST API

To view details about a job, send a GET HTTP request to the Cloud Run Admin API jobs endpoint.

For example, using curl:

curl -H "Content-Type: application/json" \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -X GET \
  -d '' \
  https://run.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobs/JOB-NAME

Replace:

  • ACCESS_TOKEN with a valid access token for an account that has the IAM permissions to view job details. For example, if you are logged into gcloud, you can retrieve an access token using gcloud auth print-access-token. From within a Cloud Run container instance, you can retrieve an access token using the container instance metadata server.
  • JOB-NAME with the name of the job.
  • REGION with the Google Cloud region of the job.
  • PROJECT-ID with the Google Cloud project ID.

Delete a job

You can delete a job only if there are no job executions of that job currently running.

Although a deleted job no longer appears in the list of jobs, its logs continue to be available in Cloud Logging for the remainder of the log retention period, and monitoring data continues to be available in Cloud Monitoring.

Console

To delete a job:

  1. Go to the Cloud Run jobs page

  2. Select the job.

  3. Click Delete.

gcloud

To delete a job:

  1. Use the command:

    gcloud run jobs delete JOB_NAME

    Replace JOB_NAME with the name of the job.

  2. If prompted to confirm, respond y. Upon success, a success message will be displayed.

Client libraries

To delete a job from code:

REST API

To delete a job, send a DELETE HTTP request to the Cloud Run Admin API jobs endpoint.

For example, using curl:

curl -H "Content-Type: application/json" \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -X DELETE \
  -d '' \
  https://run.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobs/JOB-NAME

Replace:

  • ACCESS_TOKEN with a valid access token for an account that has the IAM permissions to delete jobs. For example, if you are logged into gcloud, you can retrieve an access token using gcloud auth print-access-token. From within a Cloud Run container instance, you can retrieve an access token using the container instance metadata server.
  • JOB-NAME with the name of the job.
  • REGION with the Google Cloud region of the job.
  • PROJECT-ID with the Google Cloud project ID.