Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Sebelum menjadwalkan dan menjalankan tugas cron, Anda harus menyiapkan project dan lingkungan untuk Cloud Scheduler. Google Cloud
Aktifkan Cloud Scheduler API
Gunakan petunjuk berikut untuk membuat atau memilih Google Cloud project
dan untuk mengaktifkan Cloud Scheduler API.
Konsol
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Cara Anda melakukan autentikasi ke Cloud Scheduler bergantung pada antarmuka yang Anda gunakan untuk mengakses API dan lingkungan tempat kode Anda berjalan.
Jika akan menggunakan target HTTP App Engine, Anda harus menambahkan
aplikasi App Engine
ke project Anda. Aplikasi ini berfungsi sebagai lokasi layanan Cloud Scheduler dan handler tugas itu sendiri, yang melakukan pekerjaan yang terkait dengan tugas Cloud Scheduler, dan menampilkan konfirmasi sebagai respons.
Jika ingin memiliki pengendali tugas App Engine yang tidak ada di
project, Anda harus memilih target HTTP sebagai gantinya. Dalam hal ini, Anda tidak memerlukan aplikasi App Engine di project Anda.
Pada dialog Welcome to App Engine, lakukan salah satu hal berikut:
Jika Anda telah membuat aplikasi App Engine dan ada pesan Aplikasi App Engine Anda telah dibuat yang ditampilkan, Anda dapat melewati langkah-langkah yang tersisa di bagian ini.
atau
Jika Anda belum membuat aplikasi App Engine, klik
Create application dan lanjutkan dengan langkah-langkah yang tersisa di bagian ini.
Perhatikan bahwa europe-west dan us-central masing-masing dipanggil sebagai europe-west1 dan us-central1 dalam perintah Cloud Scheduler.
Setelah menetapkan region untuk aplikasi App Engine, Anda tidak dapat
mengubahnya.
Jangan memilih akun layanan; akun layanan App Engine default akan digunakan.
Klik Berikutnya.
Aplikasi dikonfigurasi dan dibuat. Proses ini dapat memerlukan waktu beberapa menit.
Jangan download Cloud SDK; sebagai gantinya, klik Saya akan melakukannya nanti.
Anda akan melihat pesan Your App Engine application has been created.
gcloud
Untuk membuat aplikasi App Engine, jalankan perintah
gcloud app create:
gcloudappcreate--region=REGION
Ganti REGION dengan
lokasi tempat aplikasi berjalan. Perhatikan bahwa
europe-west dan us-central masing-masing dipanggil europe-west1
dan us-central1 dalam perintah Cloud Scheduler.
Setelah menetapkan region untuk aplikasi App Engine, Anda tidak dapat
mengubahnya.
Anda dapat memeriksa region aplikasi yang ada dengan perintah berikut:
gcloudappdescribe
locationId menunjukkan wilayah. Contoh: locationId: us-central.
[[["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,["# Set up your environment\n\nBefore scheduling and running a cron job, you must set up your Google Cloud\nproject and environment for Cloud Scheduler.\n\nEnable the Cloud Scheduler API\n------------------------------\n\nUse the following instructions to create or select a Google Cloud project\nand to enable the Cloud Scheduler API. \n\n### Console\n\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\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)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\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)\n\n\u003cbr /\u003e\n\n### gcloud\n\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\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)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\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)\n\n\u003cbr /\u003e\n\nSet up authentication\n---------------------\n\nHow you authenticate to Cloud Scheduler depends on the interface you\nuse to access the API and the environment where your code is running.\n\nFor more information, see\n[Authenticate to Cloud Scheduler](/scheduler/docs/authentication) and\n[Use authentication with HTTP targets](/scheduler/docs/http-target-auth).\n\nAdd an App Engine application\n-----------------------------\n\nIf you are going to use an App Engine HTTP target, you must add an\n[App Engine application](/appengine/docs/standard/managing-projects-apps-billing)\nto your project. This app serves as both the location of the Cloud Scheduler\nservice and of the job handler itself, which performs the work associated with\na Cloud Scheduler job, and returns an acknowledgement in response.\n\nIf you want to have an App Engine job handler that is **not** in your\nproject, you should select an HTTP target instead. In this case, you don't need\nan App Engine app in your project. \n\n### Console\n\n1. In the Google Cloud console, go to the **App Engine** page.\n\n\n [Go to App Engine](https://console.cloud.google.com/appengine/start)\n\n \u003cbr /\u003e\n\n2. In the **Welcome to App Engine** dialog, do one of the\n following:\n\n - If you have already created an App Engine application and there\n is a **Your App Engine application has been created** message displayed,\n you can then skip the remaining steps in this section.\n\n or\n\n \u003cbr /\u003e\n\n - If you haven't created an App Engine application yet, then click\n **Create application** and continue with the remaining steps in this\n section.\n\n3. Select a [region](/appengine/docs/locations) for your\n application.\n\n Note that `europe-west` and `us-central` are called, respectively,\n `europe-west1` and `us-central1` in Cloud Scheduler commands.\n\n After you set a region for the App Engine app, **you can't change\n it**.\n4. Don't select a service account; the default App Engine service\n account is used.\n\n5. Click **Next**.\n\n The application is configured and created. This can take a couple of\n minutes.\n6. Don't download the Cloud SDK; instead, click **I'll do this later**.\n\n You should see a **Your App Engine application has been created** message.\n\n### gcloud\n\n1. To create an App Engine app, run the\n [`gcloud app create`](/sdk/gcloud/reference/app/create) command:\n\n gcloud app create --region=\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e with the\n [location](/appengine/docs/locations) in which the app runs. Note that\n `europe-west` and `us-central` are called, respectively, `europe-west1`\n and `us-central1` in Cloud Scheduler commands.\n\n After you set a region for the App Engine app, **you can't change\n it**.\n2. You can check the region of an existing app with the following command:\n\n gcloud app describe\n\n The `locationId` indicates the region. For example:\n `locationId: us-central`."]]