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. Notably, the logs for a job are managed separately in Cloud Logging and are subject to different retention policies.
Google Cloud automatically deletes a job 60 days after it
finishes running. A job has finished running when its status
(state
field)
indicates that the job has failed (FAILED
) or succeeded (SUCCEEDED
).
Before a job is automatically deleted, you can optionally do either of the
following:
Export the job: If you want to retain the information from the job for longer than 60 days, you can export the job. The
export-to-bigquery-delete-batch-jobs
sample script exports a job to BigQuery then deletes it. If you don't want to delete the job after exporting it, you can modify the sample script.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.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.
What's next
- View the
export-to-bigquery-delete-batch-jobs
sample script - View the jobs in your project
- Create another job