Menjadwalkan alur kerja menggunakan Cloud Scheduler
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menunjukkan cara menggunakan Cloud Scheduler untuk menjalankan alur kerja sesuai jadwal tertentu, seperti setiap hari Senin pukul 09.00 atau setiap 15 menit. Anda dapat mengonfigurasi jadwal di Google Cloud konsol atau dengan
menggunakan Google Cloud CLI.
Ganti SERVICE_ACCOUNT_NAME dengan nama yang terdiri dari 6 hingga 30 karakter. Nama ini dapat berisi karakter alfanumerik huruf kecil dan tanda hubung.
Setelah membuat akun layanan, Anda tidak dapat mengubah namanya.
SERVICE_ACCOUNT_NAME: nama akun layanan yang
sebelumnya Anda buat.
Buat tugas Cloud Scheduler yang memicu alur kerja Anda, menggunakan akun layanan yang Anda buat sebelumnya untuk melakukan autentikasi.
Perhatikan bahwa jika Anda menerapkan
logging panggilan, Anda harus mengonfigurasi
logging panggilan melalui halaman Workflows di
konsolGoogle Cloud . Untuk mengetahui detailnya, lihat langkah-langkah berikut.
Konsol
Untuk menjadwalkan alur kerja, buka halaman Workflows di konsol Google Cloud :
Di halaman Workflows, pilih alur kerja untuk membuka halaman detailnya.
Di halaman Workflow details, klik
editEdit.
Di halaman Edit alur kerja, pilih Tambahkan pemicu baru >
Cloud Scheduler.
Panel Create a Scheduler job akan terbuka.
Tentukan jadwal:
Di kolom Name, masukkan nama untuk tugas Cloud Scheduler Anda. Nama tersebut harus unik di seluruh tugas dalam region yang sama.
Dalam daftar Region, pilih region yang sesuai; misalnya, us-central1.
Di kolom Frequency, tentukan interval waktu yang Anda tentukan
dalam format unix-cron.
Misalnya, untuk menjadwalkan alur kerja Anda agar dieksekusi setiap 5 menit, ketik
*/5 * * * *.
Di daftar Zona waktu, pilih zona waktu
yang harus digunakan Cloud Scheduler untuk menafsirkan jadwal yang
Anda berikan. Anda dapat menelusuri berdasarkan negara.
Klik Lanjutkan.
Konfigurasi eksekusi:
Di kolom Argumen alur kerja, tentukan argumen runtime
yang akan diteruskan ke alur kerja Anda sebelum dieksekusi. Argumen harus dalam format
JSON. Misalnya:
{"firstName":"Sherlock", "lastName":"Holmes"}.
Jika alur kerja Anda tidak menggunakan argumen runtime, terima default
{}, atau biarkan kolom kosong.
Dalam daftar Level log panggilan alur kerja, pilih level
logging panggilan
yang ingin Anda terapkan selama eksekusi alur kerja:
Tidak ditentukan: tidak ada level logging yang ditentukan. Ini adalah setelan defaultnya.
Level log eksekusi lebih diutamakan daripada level log alur kerja apa pun, kecuali jika
level log eksekusi tidak ditentukan (default); dalam hal ini,
level log alur kerja berlaku.
Hanya error: mencatat semua pengecualian yang tertangkap; atau saat panggilan dihentikan
karena adanya suatu pengecualian.
Semua panggilan: catat semua panggilan ke sub-alur kerja atau fungsi library beserta
hasilnya.
Tidak ada pencatatan: tidak ada logging panggilan.
Dalam daftar Service account, pilih akun layanan yang
Anda buat sebelumnya.
Klik Buat.
Perhatikan bahwa jika Anda memperbarui alur kerja yang sudah ada, Anda tidak perlu
men-deploy ulang alur kerja.
Tugas Cloud Scheduler kini tercantum di tab Pemicu
di halaman Detail alur kerja.
Jika ingin memperbarui atau menghapus tugas, Anda harus mengedit alur kerja:
Di halaman Workflow details, klik
editEdit.
Di bagian Pemicu, temukan tugas yang ingin Anda perbarui atau hapus.
Klik editEdit fasilitas atau
deleteHapus fasilitas.
JOB_NAME: nama yang Anda berikan ke tugas
Cloud Scheduler.
FREQUENCY: interval waktu yang Anda tentukan menggunakan format
unix-cron.
Misalnya, untuk menjadwalkan alur kerja Anda agar dieksekusi setiap 5 menit, ketik
*/5 * * * *.
PROJECT_ID: ID Google Cloud project Anda.
REGION_NAME: region tempat Alur Kerja Anda berada, seperti
us-central1.
WORKFLOW_NAME: nama alur kerja yang ingin Anda
jadwalkan eksekusinya.
DOUBLE_ESCAPED_JSON_STRING: encoding JSON dari argumen apa pun yang Anda teruskan. Tanda kutip ganda di dalam string yang dikutip di-escape menggunakan garis miring terbalik (\). Misalnya:
--message-body="{\"argument\": \"{\\\"foo\\\": \\\"bar\\\"}\"}"
TIME_ZONE: zona waktu yang harus digunakan Cloud Scheduler untuk menafsirkan jadwal yang Anda berikan. Misalnya: America/New_York
SERVICE_ACCOUNT_NAME: nama akun layanan yang
sebelumnya Anda buat.
Untuk mencantumkan semua tugas dalam sebuah project:
gcloudschedulerjobslist
Untuk menghapus tugas:
gcloudschedulerjobsdeleteJOB_NAME
Alur kerja Anda kini dijalankan sesuai dengan frekuensi yang telah Anda tentukan.
[[["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-18 UTC."],[],[],null,["# Schedule a workflow using Cloud Scheduler\n\nThis page shows you how to use [Cloud Scheduler](/scheduler/docs) to\nrun a workflow on a particular schedule, such as every Monday at 9 AM or every\n15 minutes. You can configure the schedule either in the Google Cloud console or by\nusing the Google Cloud CLI.\n\nBefore you begin\n----------------\n\n1. If you do not already have a workflow that you want to schedule, [create and deploy one](/workflows/docs/creating-updating-workflow#creating_a_workflow).\n2.\n\n\n Enable the Cloud Scheduler API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=cloudscheduler.googleapis.com)\nOr, in a terminal, enter the following command: \n\n```bash\ngcloud services enable cloudscheduler.googleapis.com\n```\n\nSchedule a workflow\n-------------------\n\n1. Create a [service account](/workflows/docs/authentication)\n so that Cloud Scheduler can make requests to the Workflows API:\n\n ```bash\n gcloud iam service-accounts create SERVICE_ACCOUNT_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT_NAME\u003c/var\u003e with a name that is between 6 and 30\n characters. It can contain lowercase alphanumeric characters and dashes.\n After you create a service account, you cannot change its name.\n2. To allow the principal that will run your Cloud Scheduler\n commands the ability to act as an Identity and Access Management (IAM) service\n account,\n [grant a role that allows the principal to impersonate the service account](/iam/docs/service-account-permissions#roles).\n\n3. Grant your new service account the\n [workflows.invoker](/workflows/docs/access-control#roles) role so that the\n account has permission to trigger your workflow:\n\n \u003cbr /\u003e\n\n ```bash\n gcloud projects add-iam-policy-binding PROJECT_ID \\\n --member serviceAccount:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com \\\n --role roles/workflows.invoker\n ```\n\n \u003cbr /\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Google Cloud project.\n - \u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT_NAME\u003c/var\u003e: the name of the service account that you previously created.\n4. Create a Cloud Scheduler job that triggers your workflow, using the\n service account you previously created to authenticate.\n\n Note that if you are applying\n [call logging](/workflows/docs/log-workflow#call_logging), you must configure\n call logging through the **Workflows** page in the\n Google Cloud console. For details, refer to the following steps. \n\n ### Console\n\n 1. To schedule a workflow, go to the **Workflows** page in the Google Cloud console:\n\n\n [Go to Workflows](https://console.cloud.google.com/workflows)\n\n \u003cbr /\u003e\n\n 2. On the Workflows page, select a workflow to go to its\n details page.\n\n 3. On the **Workflow details** page, click\n *edit* **Edit**.\n\n 4. On the **Edit workflow** page, select **Add new trigger \\\u003e\n Cloud Scheduler**.\n\n The **Create a Scheduler job** pane opens.\n 5. Define the schedule:\n\n 1. In the **Name** field, enter a name for your Cloud Scheduler\n job. It must be unique across the jobs in the same region.\n\n 2. In the **Region** list, select an appropriate\n [region](/workflows/docs/locations); for example, **us-central1**.\n\n 3. In the **Frequency** field, specify a time interval that you define\n in a [unix-cron](/scheduler/docs/configuring/cron-job-schedules) format.\n For example, to schedule your workflow to execute every 5 minutes, type\n `*/5 * * * *`.\n\n 4. In the **Timezone** list, select the [time zone](/sdk/gcloud/reference/scheduler/jobs/create/http#--time-zone)\n that Cloud Scheduler should use to interpret the schedule you\n provide. You can search by country.\n\n 6. Click **Continue**.\n\n 7. Configure the execution:\n\n 1. In the **Workflow's argument** field, specify any [runtime arguments](/workflows/docs/passing-runtime-arguments)\n to pass to your workflow before execution. Arguments must be in JSON\n format. For example:\n `{\"firstName\":\"Sherlock\", \"lastName\":\"Holmes\"}`.\n If your workflow doesn't use runtime arguments, accept the default of\n `{}`, or leave the field blank.\n\n 2. In the **Workflow's call log level** list, select the level of\n [call logging](/workflows/docs/log-workflow#call_logging)\n that you want to apply during the execution of the workflow:\n\n - **Not specified**: no logging level is specified. This is the default. An execution log level takes precedence over any workflow log level, unless the execution log level is not specified (the default); in that case, the workflow log level applies.\n - **Errors only**: log all caught exceptions; or when a call is stopped due to an exception.\n - **All calls**: log all calls to subworkflows or library functions and their results.\n - **No logs**: no call logging.\n 3. In the **Service account** list, select the service account that\n you previously created.\n\n 8. Click **Create**.\n\n Note that if you are updating an existing workflow, you do *not* need\n to redeploy the workflow.\n\n The Cloud Scheduler job is now listed on the **Triggers**\n tab of the **Workflow details** page.\n 9. If you want to update or delete the job, you must edit the workflow:\n\n 1. On the **Workflow details** page, click *edit* **Edit**.\n 2. In the **Triggers** section, find the job you want to update or delete.\n 3. Click *edit* **Edit resource** or *delete* **Delete resource**.\n\n ### gcloud\n\n 1. Open a terminal and enter the following command:\n\n ```bash\n gcloud scheduler jobs create http JOB_NAME \\\n --schedule=\"\u003cvar translate=\"no\"\u003eFREQUENCY\u003c/var\u003e\" \\\n --uri=\"https://workflowexecutions.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eREGION_NAME\u003c/var\u003e/workflows/\u003cvar translate=\"no\"\u003eWORKFLOW_NAME\u003c/var\u003e/executions\" \\\n --message-body=\"{\\\"argument\\\": \\\"\u003cvar translate=\"no\"\u003eDOUBLE_ESCAPED_JSON_STRING\u003c/var\u003e\\\"}\" \\\n --time-zone=\"\u003cvar translate=\"no\"\u003eTIME_ZONE\u003c/var\u003e\" \\\n --oauth-service-account-email=\"\u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT_NAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e.iam.gserviceaccount.com\"\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e: the name you are giving to your Cloud Scheduler job.\n - \u003cvar translate=\"no\"\u003eFREQUENCY\u003c/var\u003e: a time interval you define using a [unix-cron](/scheduler/docs/configuring/cron-job-schedules) format. For example, to schedule your workflow to execute every 5 minutes, type `*/5 * * * *`.\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Google Cloud project.\n - \u003cvar translate=\"no\"\u003eREGION_NAME\u003c/var\u003e: the region your Workflow is in, such as `us-central1`.\n - \u003cvar translate=\"no\"\u003eWORKFLOW_NAME\u003c/var\u003e: the name of the workflow you want to schedule execution of.\n - \u003cvar translate=\"no\"\u003eDOUBLE_ESCAPED_JSON_STRING\u003c/var\u003e: a JSON encoding of any arguments you are passing. The double quotation marks inside the quoted string are escaped using backslashes (\\\\). For example: `--message-body=\"{\\\"argument\\\": \\\"{\\\\\\\"foo\\\\\\\": \\\\\\\"bar\\\\\\\"}\\\"}\"`\n - \u003cvar translate=\"no\"\u003eTIME_ZONE\u003c/var\u003e: the [time zone](/sdk/gcloud/reference/scheduler/jobs/create/http#--time-zone) that Cloud Scheduler should use to interpret the schedule you provide. For example: `America/New_York`.\n - \u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT_NAME\u003c/var\u003e: the name of the service account that you previously created.\n 2. To list all jobs in a project:\n\n ```bash\n gcloud scheduler jobs list\n ```\n\n \u003cbr /\u003e\n\n 3. To delete a job:\n\n ```bash\n gcloud scheduler jobs delete JOB_NAME\n ```\n\n \u003cbr /\u003e\n\nYour workflow now executes according to the frequency you have defined.\n| **Note:** Each execution of a workflow incurs costs, as detailed in [Workflows pricing](/workflows/pricing). To stop incurring costs from a scheduled workflow, [delete the Cloud Scheduler job](/sdk/gcloud/reference/scheduler/jobs/delete).\n\nWhat's next\n-----------\n\n- [Use IAM to control access](/workflows/docs/use-iam-for-access)\n- [Pass runtime arguments in an execution request](/workflows/docs/passing-runtime-arguments)\n- [Tutorial: Schedule Workflows with Cloud Scheduler](/scheduler/docs/tut-workflows)"]]