Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Latest commit

 

History

History
83 lines (51 loc) · 3.55 KB

scheduling-periodic-jobs-with-cloud-scheduler.md

File metadata and controls

83 lines (51 loc) · 3.55 KB
title description author tags date_published
Schedule periodic jobs with Cloud Scheduler
Schedule virtually any job, including batch jobs, big data jobs, and cloud infrastructure operations with Cloud Scheduler.
timtech4u
Cloud Scheduler, Cron, Automation
2019-12-03

Contributed by the Google Cloud community. Not official Google documentation.

Automating tasks that re-occur is definitely at the heart of every software developer. Google Cloud provides Cloud Scheduler, a tool that allows users to schedule jobs with the conventional unix-cron format.

Cloud Scheduler can be referred to as a cron-job-as-a-service tool. It is fully managed by Google Cloud, so you don't need to manage the scheduler's underlying infrastructure.

Cloud Scheduler can be used for multiple use cases, such as making requests to an HTTP/S endpoint, invoking a Pub/Sub topic, making database updates and push notifications, triggering CI/CD pipelines, scheduling tasks such as image uploads and sending email, and even invoking Cloud Functions.

Objective

In this tutorial, you use Cloud Scheduler to make simple requests to an HTTP endpoint.

Before you begin

  1. Set up a Google Cloud account and project.

  2. Enable Cloud Scheduler.

  3. Copy the URL of the HTTP endpoint that you would like to make requests to.

Get the sample code

The author of this tutorial built a tool that periodically makes request to Cloud Run services to prevent them from having cold starts. Get the code from GitHub.

Setting up Cloud Scheduler

  1. Visit Cloud Scheduler and click Create Job

  2. Enter the job name.

  3. Frequency: Enter every 24 hours, or enter another value to suit your use case.

  4. Target: Select HTTP.

  5. URL: Enter the application or function URL.

  6. HTTP Method: Select GET.

  7. Click Create.

Next steps

If you face problems with HTTP headers or other issues while using Cloud Scheduler, check out John Hanley's answers on Stack Overflow..

Cloud Scheduler can also be used with Firebase Cloud Functions, which automatically configures Cloud Scheduler, along with a Pub/Sub topic that invokes the function that you define using the Cloud Functions for Firebase SDK. (Read more.)

Stackdriver integrates with Cloud Scheduler, providing powerful logging for greater transparency into job execution and performance.

Pricing

Cloud Scheduler is simple and pay-for-use. You pay for the number of jobs you use each month. Google Cloud allows you create three free jobs per month, and you pay for others at $0.10/job/month.

Resources

If you want to learn more about Cloud Scheduler, check out the following resources:

Thanks for reading through! Let me know if I missed anything, if something didn’t work out quite right for you, or if this guide was helpful.