一键导入
gcloud-batch
Batch via gcloud (`gcloud batch`). Manage Batch resources — jobs, tasks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Batch via gcloud (`gcloud batch`). Manage Batch resources — jobs, tasks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
gcloud CLI reference: 128 GCP services, all GA commands with full flags, plus the standalone bq CLI. Use for any Google Cloud / GCP command-line task — managing resources, debugging gcloud commands, auth/config/scripting — or whenever a GCP product is named (GKE, Cloud Run, BigQuery, Cloud SQL, Pub/Sub...), even without 'gcloud'.
Access Approval via gcloud (`gcloud access-approval`). Manage Access Approval requests and settings — requests, service-account, settings.
Access Context Manager (VPC Service Controls) via gcloud (`gcloud access-context-manager`). Manage Access Context Manager resources — authorized-orgs, cloud-bindings, levels, perimeters, policies, supported-services.
Managed Service for Microsoft AD via gcloud (`gcloud active-directory`). Manage Managed Microsoft AD resources — domains, operations, peerings.
Agent Registry via gcloud (`gcloud agent-registry`). Manage Agent Registry resources — agents, bindings, endpoints, mcp-servers, operations, services.
AI Platform (legacy) via gcloud (`gcloud ai-platform`). Manage AI Platform jobs and models — jobs, local, models, operations, versions.
| name | gcloud-batch |
| description | Batch via gcloud (`gcloud batch`). Manage Batch resources — jobs, tasks. |
Google Cloud Batch is a fully managed service that schedules, queues, and runs batch
computing workloads on Compute Engine VMs. You define a job containing one or more
task groups (currently a single group, group0), each holding identical tasks that
run a script or container runnable; Batch handles VM provisioning, autoscaling, retries, and
log routing for you. Reach for gcloud batch when you need to run fan-out, fault-tolerant, or
high-throughput compute jobs without managing the underlying cluster. There is no charge for
Batch itself beyond the Compute Engine resources it provisions.
Batch provisions VMs and writes task logs, so enable all three APIs:
gcloud services enable batch.googleapis.com compute.googleapis.com logging.googleapis.com
# Optional: set a default location so you can omit --location on later commands
gcloud config set batch/location us-central1
# hello.json defines taskGroups -> taskSpec -> runnables (script), taskCount, parallelism
gcloud batch jobs submit my-job \
--location=us-central1 \
--config=hello.json
The config file may be JSON or YAML; pass --config=- to read it from stdin or a HereDoc.
# Provide the runnable directly via --script-text (or --script-file-path for a local file)
gcloud batch jobs submit my-script-job \
--location=us-central1 \
--script-text='echo Hello from task ${BATCH_TASK_INDEX}' \
--machine-type=e2-standard-4
gcloud batch jobs submit my-container-job \
--location=us-central1 \
--container-image-uri=gcr.io/google-containers/busybox \
--container-entrypoint=sh \
--container-commands-file=commands.txt \
--provisioning-model=SPOT \
--machine-type=e2-standard-4
# Generates an ID like nightly-etl-20260527-140523 (prefix + %Y%m%d-%H%M%S)
gcloud batch jobs submit \
--location=us-central1 \
--job-prefix=nightly-etl \
--config=job.yaml
# List all jobs across all locations for the default project
gcloud batch jobs list
# List jobs in a specific project/location
gcloud batch jobs list --project=my-project --location=us-central1
# Describe one job (short ID + --location, or a fully qualified name)
gcloud batch jobs describe my-job --location=us-central1
# List every task in group0 of a job
gcloud batch tasks list --job=my-job --location=us-central1
# Describe a single task by index
gcloud batch tasks describe 0 \
--job=my-job \
--location=us-central1 \
--task_group=group0
# Cancel a running job (stops scheduling new tasks)
gcloud batch jobs cancel my-job --location=us-central1
# Delete a finished or cancelled job
gcloud batch jobs delete my-job --location=us-central1
# Fully qualified resource name needs no --location
gcloud batch jobs cancel projects/my-project/locations/us-central1/jobs/my-job
| Group | Reference file | Commands | Description |
|---|---|---|---|
batch jobs | jobs.md | 5 | Manage Batch job resources (submit, list, describe, cancel, delete) |
batch tasks | tasks.md | 2 | Manage Batch task resources (list, describe) within a job's group0 |
See index.md for a one-line index of all 7 GA commands.
--location (a Compute Engine
region such as us-central1). Set gcloud config set batch/location REGION once, or pass a
fully qualified resource name (projects/PROJECT/locations/REGION/jobs/JOB) and the location
is inferred — no --location needed.jobs submit, give an explicit JOB positional ID, or omit it and
use --job-prefix to auto-generate prefix-%Y%m%d-%H%M%S. You cannot specify both.jobs submit requires one of --config (JSON/YAML file,
- for stdin), --script-text, --script-file-path, or the container flags
(--container-image-uri with --container-entrypoint / --container-commands-file).--provisioning-model accepts SPOT or STANDARD;
--machine-type sets the VM (e.g. e2-standard-4); --priority takes 0–99 (0 lowest).--network together with --subnetwork (both required if either is set),
and --no-external-ip-address when VMs should have no public IP.group0. Batch supports a single task group per job, so
tasks describe uses --task_group=group0 and tasks list only needs --job.jobs list and tasks list support the standard
--filter, --limit, --page-size, and --sort-by flags, e.g.
gcloud batch jobs list --location=us-central1 --filter="status.state=SUCCEEDED" --sort-by=~createTime.gcloud beta batch mirrors the GA surface (same jobs and tasks groups and commands);
no beta-exclusive features were identified.gcloud alpha batch adds a third command group,
gcloud alpha batch resource-allowances (create, delete, describe, list,
update), which manages resource-allowance objects that cap resource consumption across jobs
in a project/location. This is invitation-only alpha and may change without notice.resource-allowances.