Created
August 20, 2025 20:32
-
-
Save wnojopra/340222fc6a3b8e58da4660e4c5a2cb06 to your computer and use it in GitHub Desktop.
Script demonstrating % issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| PROJECT_ID="MY_PROJECT_ID" | |
| LOCATION="us-central1" | |
| BUCKET="gs://my-bucket" | |
| # Autogenerate job name with timestamp + random | |
| JOB_NAME="job-$(date +%Y%m%d-%H%M%S)-$RANDOM" | |
| gcloud beta batch jobs submit "$JOB_NAME" \ | |
| --location "$LOCATION" \ | |
| --config - <<EOD | |
| { | |
| "name": "projects/${PROJECT_ID}/locations/${LOCATION}/jobs/${JOB_NAME}", | |
| "taskGroups": [ | |
| { | |
| "taskCount": "1", | |
| "parallelism": "1", | |
| "taskSpec": { | |
| "computeResource": { | |
| "cpuMilli": "1000", | |
| "memoryMib": "512" | |
| }, | |
| "runnables": [ | |
| { | |
| "container": { | |
| "imageUri": "gcr.io/google.com/cloudsdktool/cloud-sdk:294.0.0-slim", | |
| "volumes": "/mnt/disks/data:/mnt/data", | |
| "entrypoint": "/bin/bash", | |
| "commands": [ | |
| "-c", | |
| "mkdir -p /mnt/data/.logging && echo \"%hel%lo%\" && sleep 10 && gsutil cp /mnt/data/.logging/stdout*.log ${BUCKET}/stdout.txt" | |
| ] | |
| } | |
| } | |
| ], | |
| "volumes": [] | |
| } | |
| } | |
| ], | |
| "allocationPolicy": { | |
| "network": { | |
| "networkInterfaces": [ | |
| { | |
| "network": "projects/${PROJECT_ID}/global/networks/default", | |
| "subnetwork": "projects/${PROJECT_ID}/regions/us-central1/subnetworks/default", | |
| "noExternalIpAddress": true | |
| } | |
| ] | |
| }, | |
| "instances": [ | |
| { | |
| "policy": { | |
| "provisioningModel": "STANDARD", | |
| "machineType": "e2-medium" | |
| } | |
| } | |
| ] | |
| }, | |
| "logsPolicy": { | |
| "destination": "PATH", | |
| "logsPath": "/mnt/disks/data/.logging/" | |
| } | |
| } | |
| EOD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment