How to create cron tasks in Firebase

A few days ago, I was wondering how to call a function programmatically using Firebase Cloud Functions.

Firebase team introduced chron jobs on April 18, 2019. The problem is that Cloud Scheduler needs billing information and each Cloud Scheduler job costs $0.10 (USD) per month.

If you don't want to give your billing data, there is a method to create simple cron tasks for free.

Google Drive Spreadsheet

  1. Go to Google Drive and create a new spreadsheet
  2. On the top menu, click on Tools > Script Editor
  3. Write this function
jsx
function chronJob(){
  
  // Defining the target URL
  var url = "CLOUD_FUNCTIONS_URL";
  
  // Fetching the URL
  var response = UrlFetchApp.fetch(url);
  
}

Full screen code block

  1. Save the file and click on the timer button

Timer button

  1. Add new trigger

Trigger

  1. Select Time-driven trigger

![Time driven trigger] (https://firebasestorage.googleapis.com/v0/b/autosnapshoturl.appspot.com/o/ecedf6eaec726462592773c11dbda9cd9eaa66751d96ae0c5e1b8949be655b0b%2F1577858548236.png?alt=media&token=9a94bcb5-a8f8-4a6d-8d36-36166b4e361a)

  1. Choose the frequency to call the function (monthly, weekly, daily, etc.)

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.