0
0
GCPcloud~30 mins

Cloud Scheduler for cron jobs in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Cloud Scheduler for cron jobs
📖 Scenario: You work for a company that needs to run a task every day at 9 AM to clean up old files in a storage bucket. You will use Google Cloud Scheduler to create a cron job that triggers a Cloud Function daily.
🎯 Goal: Create a Cloud Scheduler job with a cron schedule that triggers a Cloud Function every day at 9 AM.
📋 What You'll Learn
Create a Cloud Scheduler job resource with the exact name daily-cleanup-job.
Set the schedule to run every day at 9 AM using cron syntax.
Configure the job to use the HTTP target with the exact URI https://us-central1-your-project.cloudfunctions.net/cleanupFunction.
Set the HTTP method to POST.
💡 Why This Matters
🌍 Real World
Cloud Scheduler is used to automate tasks like backups, cleanups, and report generation by running jobs on a schedule.
💼 Career
Knowing how to configure Cloud Scheduler jobs is essential for cloud engineers and DevOps professionals managing automated workflows in Google Cloud.
Progress0 / 4 steps
1
Create the Cloud Scheduler job resource
Create a Cloud Scheduler job resource named daily-cleanup-job in YAML format with an empty schedule and target section.
GCP
Need a hint?

Start by defining the job with the name daily-cleanup-job. Leave schedule and httpTarget empty for now.

2
Add the cron schedule
Add the schedule to run every day at 9 AM using the cron expression 0 9 * * * under the spec section of the daily-cleanup-job resource.
GCP
Need a hint?

The cron expression 0 9 * * * means every day at 9 AM.

3
Configure the HTTP target URI and method
Set the httpTarget section with the exact URI https://us-central1-your-project.cloudfunctions.net/cleanupFunction and HTTP method POST inside the daily-cleanup-job resource.
GCP
Need a hint?

Use uri and httpMethod keys inside httpTarget.

4
Add the timezone configuration
Add the timeZone field with the value America/Los_Angeles under the spec section of the daily-cleanup-job resource to ensure the job runs at 9 AM in that timezone.
GCP
Need a hint?

Adding timeZone ensures the job triggers at the correct local time.