GAS AI BuilderApps Script Assistant Sign in

Run a function every day at a set hour

Apps Script recipes › Triggers and long jobs

Installs one time trigger for a function, removing older ones for it first so it never runs twice.

File Code.gs

function installDaily() {
  ScriptApp.getProjectTriggers()
    .filter(t => t.getHandlerFunction() === 'dailyJob')
    .forEach(t => ScriptApp.deleteTrigger(t));
  ScriptApp.newTrigger('dailyJob').timeBased().everyDays(1).atHour(7).create();
  return 'dailyJob runs every day between 07:00 and 08:00.';
}

function dailyJob() {
  // What should happen every morning, e.g. email the items that are due.
}

Good to know

Let the AI put it in your appGAS AI Builder knows every recipe here. Describe your app and it uses this code where it fits, in a Google Apps Script project in your own Drive.

Use it in a project

More in Triggers and long jobs

Finish a long job in parts (6-minute limit)Works through rows until about 5 minutes have passed, remembers where it stopped, and schedules itself to go on.Stamp the time when a row is editedAn onEdit function writes the time into an "Updated" column whenever someone edits that row.