Recipe
Run an Apps Script function every day at a set time
Creates one daily time-driven trigger for a function you name, removing any older copy so you never end up with duplicates.
Set it up
- Paste the script, set handler and hour in DT, and add a tab named Log.
- Run installDailyTrigger once and approve the prompts.
- Open Triggers (clock icon) to confirm one entry for dailyJob.
The script
/**
* Run a function every day at a set hour.
* Run installDailyTrigger once from the editor. Edit dailyJob to do your work.
*/
var DT = { handler: 'dailyJob', hour: 8 };
function installDailyTrigger() {
ScriptApp.getProjectTriggers().forEach(function (t) {
if (t.getHandlerFunction() === DT.handler) ScriptApp.deleteTrigger(t);
});
ScriptApp.newTrigger(DT.handler).timeBased().everyDays(1).atHour(DT.hour).create();
return 'installed';
}
function dailyJob() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Log');
sheet.appendRow([new Date(), 'dailyJob ran']);
return 'ran';
}Test status. 3 of 3 automated checks pass, run Nov 2026 against simulated Google services. This recipe has not yet been run inside a live Google account. Test it on a copy of your sheet first.
What you should see
| Time | Message |
|---|---|
| 2026-11-13 08:12 | dailyJob ran |
| 2026-11-14 08:31 | dailyJob ran |
The Log tab after two days. Sample values, not output from a real account.
Common errors and fixes
- The job runs at a slightly different minute
- Time-driven triggers run within the chosen hour, not at an exact minute.
- Two runs every day
- An old trigger exists. installDailyTrigger deletes older ones for the same handler.
- Exceeded maximum execution time
- A single run is limited. Split the work with the batching fix.
Permissions. Running this script asks you to grant Google permissions for the services listed above, to your own script. TriggerShelf never receives your Google data. See the permissions table. Google will show "Google hasn't verified this app"; that is expected for a script you paste yourself.
TriggerShelf is independent and not affiliated with or endorsed by Google LLC. Google Sheets, Gmail, Google Drive and Apps Script are trademarks of Google LLC. Quota figures come from Google's Apps Script quotas page. Test on a copy first.