Calculating... until our next FREE Code-Along Session. Secure your spot now

Build Your First Web App Today

Your 14-Day Free Trial Is Waiting To Be Activated
GET INSTANT ACCESS READ MORE ABOUT FIVE

How To Schedule a Google Apps Script To Run

Avatar photo
Dominik Keller
Feb 12th, 2025
Blog

Is It Possible to Schedule and Automatically Run a Google Apps Script?

Welcome to this how-to series for Google Apps Script users! Whether you’re a seasoned developer or just dipping your toes into the world of automation, Google Apps Script is a powerful tool that can help you streamline tasks, automate workflows, and integrate Google services seamlessly. In this series, we’re exploring practical tips and tricks to help you get the most out of Apps Script, from writing your first script to deploying advanced automation solutions.

In today’s post, we’re diving into a topic that’s essential for anyone looking to automate repetitive tasks: how to schedule a Google Apps Script to run automatically. Imagine having a script that sends daily email reminders, updates a Google Sheet with fresh data, or syncs information between Google Drive and an external database—all without lifting a finger. By the end of this guide, you’ll know exactly how to set up time-driven triggers to make your scripts run like clockwork.

Let’s get started!



Meet Five, The Advanced Rapid Application Builder

If Apps Script and Google Sheets are your go-to tools for automation, data storage and interface design, you have probably designed a few great automations or integrations for your own use, your business or your clients. Where to take this next?

Five, a rapid application development environment, takes Google Sheets and Apps Script to the next level. With Five, you can:

✅ Set up and connect to a data source, such as a SQL database, an API or OData endpoint.
✅ Write automations or integrations in JavaScript and trigger or schedule functions based on client- or server-side events, such as onEdit, onCancel, or onPress – the same way you do in Google Sheets and Apps Script.
✅ Get an auto-generated, responsive user interface that looks and feels much more professional than a spreadsheet.
✅ Use role-based access control (RBAC) to create user roles with different CRUD permissions.
✅ Authenticate users through Single Sign-On, 2-Factor Authentication or username and password to share data securely.

Say goodbye to clunky spreadsheet automations. Automate processes in a professional, cloud-native web app instead. Schedule jobs, share data securely, and integrate with 3rd party platforms – all from within Five, an all-in-one tool for building and launching custom software.

Check out some of our sample applications below to better understand the user interface of applications developed in Five or sign up for a free trial to get started.

Sample Apps

Check out our AI-powered email extractor and learn how to build it here. Or check out this project management tool developed entirely in Five with just a few lines of code.



Integrate, Automate, Perform Tasks
Rapidly build and deploy professional web apps




Time-Driven Triggers in Google Apps Script

Time-driven triggers, also known as clock triggers, are a powerful feature in Google Apps Script that allow you to automate the execution of your scripts at specific times or on recurring intervals. These triggers fall under the category of installable triggers, which are designed to handle events that aren’t directly tied to user actions (like opening a document or submitting a form). Instead, time-driven triggers enable your scripts to run automatically based on a schedule, making them ideal for tasks that need to happen regularly without manual intervention.

How Time-Driven Triggers Work

Time-driven triggers function similarly to cron jobs in Unix-based systems. You can configure them to execute your script:

  • As frequently as every minute.
  • As infrequently as once per month.
  • At a specific time of day (e.g., 9 AM).
  • On a recurring basis (e.g., daily, weekly, or monthly).

One important thing to note is that add-ons (Apps Script projects published to the Google Workspace Marketplace) are subject to stricter limitations—they can only use time-driven triggers once per hour at most.

Randomized Timing for Consistency

When you set up a time-driven trigger, Apps Script may slightly randomize the execution time to optimize system performance. For example, if you create a trigger to run daily at 9 AM, Apps Script might choose a time between 9 AM and 10 AM initially. However, once the time is set, it remains consistent from day to day, ensuring that 24 hours elapse between each execution. This randomization helps distribute the load on Google’s servers while maintaining the reliability of your scheduled tasks.


Time-driven triggers are incredibly versatile and can be used for a wide range of automation tasks, such as:

  • Sending daily email reports.
  • Updating Google Sheets with fresh data.
  • Backing up files to Google Drive.
  • Syncing data between Google services and external APIs.

In the next section, we’ll walk through the steps to create and manage time-driven triggers for your Apps Script projects. Let’s dive in!


How to Add a Time-Driven Trigger in Google Sheets to Schedule a Task

In this section, we’ll walk through the steps to set up a time-driven trigger in Google Apps Script that invokes a function every minute. This is particularly useful for tasks that require frequent execution, such as monitoring data, sending notifications, or updating records.

We’ll use the provided onTrigger function as an example, which posts a message with the current date and time to a predefined set of spaces (e.g., Google Chat spaces).

Step 1: Write Your Function

First, ensure you have a function in your Apps Script project that you want to trigger. Here’s the example function provided:

function onTrigger() {
  // Retrieve stored space IDs from script properties
  var spaceIds = PropertiesService.getScriptProperties().getKeys();

  // Create a message with the current date and time
  var message = { 'text': 'Hi! It\'s now ' + (new Date()) };

  // Loop through each space ID and post the message
  for (var i = 0; i < spaceIds.length; ++i) {
    postMessage(spaceIds[i], message);
  }
}

This function retrieves a list of space IDs from the script properties, creates a message with the current date and time, and posts it to each space using a hypothetical postMessage function (remember to define this function).

You can replace this logic with any action you want to perform every minute.

Step 2: Open the Triggers Menu

  1. Open your Google Apps Script project (e.g., the script attached to your Google Sheet).
  2. In the Apps Script editor, click on the Triggers icon (the clock symbol) in the left sidebar, or go to Edit > Current Project’s Triggers.

Step 3: Add a New Trigger

  1. In the Triggers page, click on the + Add Trigger button in the bottom right corner.
  2. Configure the trigger settings as follows:
  • Choose which function to run: Select onTrigger (or the name of your function).
  • Choose which deployment should run: Select Head (this refers to the latest version of your script).
  • Select event source: Choose Time-driven.
  • Select type of time-based trigger: Choose Minute timer.
  • Select minute interval: Choose Every minute.

3. Click Save.

Step 4: Authorize the Trigger

If this is your first time setting up a trigger, you’ll be prompted to authorize the script. Follow these steps:

  1. Click Review Permissions.
  2. Select your Google account.
  3. Click Allow to grant the necessary permissions.

Step 5: Verify the Trigger

Once the trigger is set up, it will automatically run the onTrigger function every minute. You can verify that it’s working by:

  • Checking the Execution Logs in the Apps Script editor (under Executions in the left sidebar).
  • Observing the output of your scheduled function, such as the postMessage function above.

Notes and Best Practices

  • Randomization: As mentioned earlier, Apps Script may slightly randomize the execution time for triggers. While the function is set to run every minute, there might be a small delay (a few seconds) between executions.
  • Quotas and Limits: Be mindful of Google Apps Script’s daily quotas and limitations, especially if your function performs resource-intensive tasks or interacts with external APIs.
  • Error Handling: Add error handling to your function to ensure it can recover gracefully from unexpected issues.

By following these steps, you’ve successfully set up a time-driven trigger to run your function every minute. This powerful feature allows you to automate repetitive tasks and focus on more important aspects of your projects.

Happy scripting!


Start developing your first application!

Get Started For Free Today

Sign Up Free Book a demo

Build Your Web App With Five

200+ Free Trials Started This Week

Start Free

Thank you for your message!

Our friendly staff will contact you shortly.

CLOSE