Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird beschrieben, wie Sie Batch-Jobs abbrechen.
Brechen Sie Jobs ab, die Sie nicht mehr ausführen möchten oder die nicht ausgeführt werden sollen.
Im Idealfall sollten Sie Ihre Jobs so konfigurieren, dass sie automatisch beendet werden und fehlschlagen, wenn sie sich nicht wie vorgesehen verhalten. Konfigurieren Sie Ihre ausführbaren Dateien beispielsweise so, dass sie einen Exit-Code ungleich null oder timeout zurückgeben.
In der Praxis kann es jedoch sinnvoll sein, unvollständige Jobs manuell zu beenden. Sie können beispielsweise einen Job abbrechen, wenn Sie feststellen, dass Sie einen Job, der noch nicht abgeschlossen ist, ersetzen oder Fehler beheben müssen.
Wie erfolgreiche und fehlgeschlagene Jobs bleibt ein abgebrochener Job bis zu 60 Tage lang in Ihrem Projekt. Danach wird er von Google Cloud automatisch gelöscht. Wenn Sie einen Job abbrechen und die Informationen des Jobs nicht beibehalten möchten, können Sie ihn stattdessen sofort löschen.
Bitten Sie Ihren Administrator, Ihnen die IAM-Rolle Batch Job Editor (roles/batch.jobsEditor) für das Projekt zuzuweisen, damit Sie die Berechtigungen erhalten, die Sie zum Abbrechen eines Jobs benötigen.
Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff auf Projekte, Ordner und Organisationen verwalten.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-02 (UTC)."],[[["\u003cp\u003eThis page outlines the process for canceling Batch jobs, which is useful for stopping jobs that are running or preventing jobs from starting.\u003c/p\u003e\n"],["\u003cp\u003eCanceling a job can be done manually, for example, when a job requires troubleshooting, or it should be configured to automatically stop by a non-zero exit code or timeout.\u003c/p\u003e\n"],["\u003cp\u003eTo cancel a job, you need the Batch Job Editor role (\u003ccode\u003eroles/batch.jobsEditor\u003c/code\u003e) and can do so using either the \u003ccode\u003egcloud alpha batch jobs cancel\u003c/code\u003e command in the Google Cloud CLI or the \u003ccode\u003ejobs.cancel\u003c/code\u003e v1alpha method in the Batch API.\u003c/p\u003e\n"],["\u003cp\u003eCancelled jobs, similar to succeeded and failed jobs, remain in the project for 60 days before being automatically deleted by Google Cloud, but you can delete the job immediately to not keep the information if desired.\u003c/p\u003e\n"],["\u003cp\u003eBefore canceling a job, make sure to have enabled Batch and completed the prerequisites, and remember to replace placeholders like \u003ccode\u003eJOB_NAME\u003c/code\u003e and \u003ccode\u003eLOCATION\u003c/code\u003e with your specific job and location details.\u003c/p\u003e\n"]]],[],null,["# Cancel jobs\n\nThis page describes how to cancel Batch jobs.\nCancel jobs that you want to stop running or prevent from running.\n\nIdeally, you should configure your jobs to automatically stop running and\nfail whenever they don't behave as intended. For example, configure your\nrunnables to return a non-zero exit code or [timeout](/batch/docs/set-timeouts).\nBut, in practice, you might still want to manually stop unfinished\njobs. For example, cancel a job when you notice you need to troubleshoot or\nreplace a job that hasn't finished yet.\n\nLike succeeded and failed jobs, a cancelled job remains in your project for up\nto 60 days, after which Google Cloud automatically deletes the job. If you\nwant to cancel a job and don't need to retain the job's information, then you\ncan immediately [delete the job](/batch/docs/delete-job) instead.\n\nBefore you begin\n----------------\n\n1. If you haven't used Batch before, review [Get started with Batch](/batch/docs/get-started) and enable Batch by completing the [prerequisites for projects and users](/batch/docs/get-started#prerequisites).\n2.\n\n To get the permissions that\n you need to cancel a job,\n\n ask your administrator to grant you the\n\n\n [Batch Job Editor](/iam/docs/roles-permissions/batch#batch.jobsEditor) (`roles/batch.jobsEditor`)\n IAM role on the project.\n\n\n For more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\n You might also be able to get\n the required permissions through [custom\n roles](/iam/docs/creating-custom-roles) or other [predefined\n roles](/iam/docs/roles-overview#predefined).\n\n\u003cbr /\u003e\n\nCancel a job\n------------\n\nYou can cancel a job using the gcloud CLI or\nBatch API. \n\n### gcloud\n\nTo cancel a job using the gcloud CLI, use the\n[`gcloud batch jobs cancel` command](/sdk/gcloud/reference/batch/jobs/cancel): \n\n gcloud batch jobs cancel \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e --location \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e: the name of the job.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the [location](/batch/docs/locations) of the job.\n\n### API\n\nTo cancel a job using the Batch API, use the\n[`jobs.cancel` method](/batch/docs/reference/rest/v1/projects.locations.jobs/cancel): \n\n POST https://batch.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/jobs/\u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e:cancel\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the [project ID](/resource-manager/docs/creating-managing-projects#identifying_projects) of your project.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the [location](/batch/docs/locations) of the job.\n- \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e: the name of the job.\n\nWhat's next\n-----------\n\n- Learn how to [limit run times using timeouts](/batch/docs/set-timeouts).\n- Learn about [troubleshooting](/batch/docs/troubleshooting).\n- Learn how to manage jobs:\n - [View the jobs in your project](/batch/docs/view-jobs-tasks).\n - [Export job information](/batch/docs/export-job-info).\n - [Delete jobs](/batch/docs/delete-job).\n- [Create another job](/batch/docs/create-run-job#job-creation-options)."]]