This page describes how to delete and export Batch jobs.
When a job is deleted, the job's details and history that appear when you view a job and its tasks are removed from Batch. If you want to remove all the information and resources associated with a job, you need to also delete items from any additional Google Cloud products that you enabled, such as Pub/Sub topics, BigQuery tables, or Cloud Logging logs.
Google Cloud automatically deletes a job 60 days after it is cancelled (Preview), succeeds, or fails. Before a job is automatically deleted, you can optionally do either of the following:
Export job information: If you want to retain the information from the job for longer than 60 days, you can export the job information to BigQuery by using Workflows. For more information, see Export job information.
Delete a job: As explained in this document, you can manually delete a job when you are ready to remove it from your project's list of jobs and no longer need the job's history. If you delete a job before or while it is running, the job is canceled.
Before you begin
- If you haven't used Batch before, review Get started with Batch and enable Batch by completing the prerequisites for projects and users.
-
To get the permissions that you need to delete a job, ask your administrator to grant you the Batch Job Editor (
roles/batch.jobsEditor
) IAM role on the project. For more information about granting roles, see Manage access to projects, folders, and organizations.You might also be able to get the required permissions through custom roles or other predefined roles.
Delete a job
You can delete a job using the Google Cloud console, gcloud CLI, Batch API, Go, Java, Node.js, Python, or C++.
Console
To delete a job using the Google Cloud console, do the following:
In the Google Cloud console, go to the Job list page.
Click the name of the job you created. The Job details page opens.
Click
Delete.In the Delete batch job? dialog, for the field, enter
Delete
.Click Delete.
The Job list page displays that the job is deleted.
gcloud
To delete a job using the gcloud CLI, use the
gcloud batch jobs delete
command.
gcloud batch jobs delete JOB_NAME --location LOCATION
Replace the following:
JOB_NAME
: the name of the job.LOCATION
: the location of the job.
API
To delete a job using the Batch API, use the
jobs.delete
method:
DELETE https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs/JOB_NAME
Replace the following:
PROJECT_ID
: the project ID of your project.LOCATION
: the location of the job.JOB_NAME
: the name of the job.
Go
Go
For more information, see the Batch Go API reference documentation.
To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
Java
For more information, see the Batch Java API reference documentation.
To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
Node.js
For more information, see the Batch Node.js API reference documentation.
To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
Python
For more information, see the Batch Python API reference documentation.
To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
C++
C++
For more information, see the Batch C++ API reference documentation.
To authenticate to Batch, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.