Back to homepage

Google Cloud Scheduler

Published on 18/04/2021
Cron job? Try Cloud Scheduler of Google Cloud Platform

The latest Firebase CLI can't publish my scheduled PubSub function correctly. I had to investigate and found, in the background, a scheduled function is associated with a GCP Cloud Scheduler.

The following code is a PubSub function calling a API every day 6am.

exports.scheduleCrawler = functions.pubsub
  .schedule('0 6 * * *')
  .timeZone('Pacific/Auckland')
  .onRun(async (context) => {
    await fetch('https://abcd.cloudfunctions.net/crawler');
});
Screen Shot on 2021-04-19 at 15:30:23.png

Cloud Scheduler can also make HTTP requests. That means I can actually get rid off the function above and just use the scheduler to call the API on scheduled time.

Screen Shot on 2021-04-19 at 15:31:16.png

The Cloud Scheduler gives JAM stack websites more potential.

Be the first
to get my latest blog
Comments