Schedule periodic jobs with Cloud Scheduler
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.
In this tutorial, you use Cloud Scheduler to make simple requests to an HTTP endpoint.
Before you begin
Set up a Google Cloud account and project.
Enable Cloud Scheduler.
Copy the URL of the HTTP endpoint that you would like to make requests to.
Get the sample code
Setting up Cloud Scheduler
Visit Cloud Scheduler and click Create Job
Enter the job name.
every 24 hours, or enter another value to suit your use case.
Target: Select HTTP.
URL: Enter the application or function URL.
HTTP Method: Select GET.
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.
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.
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.