Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara membatalkan tugas Batch.
Membatalkan tugas yang ingin Anda hentikan atau cegah agar tidak berjalan.
Sebaiknya konfigurasi tugas Anda agar otomatis berhenti berjalan dan gagal setiap kali tidak berfungsi sebagaimana mestinya. Misalnya, konfigurasi
runnable Anda untuk menampilkan kode keluar bukan nol atau waktu tunggu.
Namun, dalam praktiknya, Anda mungkin masih ingin menghentikan tugas yang belum selesai secara manual. Misalnya, batalkan tugas saat Anda menyadari bahwa Anda perlu memecahkan masalah atau
mengganti tugas yang belum selesai.
Seperti tugas yang berhasil dan gagal, tugas yang dibatalkan akan tetap ada di project Anda hingga 60 hari, setelah itu Google Cloud akan menghapus tugas secara otomatis. Jika Anda ingin membatalkan tugas dan tidak perlu menyimpan informasi tugas, Anda dapat langsung menghapus tugas.
Untuk mendapatkan izin yang diperlukan guna membatalkan tugas, minta administrator untuk memberi Anda peran IAM Batch Job Editor (roles/batch.jobsEditor) di project.
Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.
Anda mungkin juga bisa mendapatkan
izin yang diperlukan melalui peran
khusus atau peran
bawaan lainnya.
Membatalkan tugas
Anda dapat membatalkan tugas menggunakan gcloud CLI atau Batch API.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-12 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)."]]