-
-
Save basil2style/b72f03feddfb74f09b15673062ab7c64 to your computer and use it in GitHub Desktop.
Cron Scheduler in Google Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is a cron job scheduler wrintten in Google App Script which insert Success and timestamp to Google Sheet if its | |
#successfully fetch the url otherwise it will return Error | |
var sheet = 'Sheet1'; | |
function myFunction() { | |
var url = 'YOUR URL HERE'; | |
var options = { | |
'method': 'get' | |
}; | |
try { | |
var response = UrlFetchApp.fetch(url, options); | |
Logger.log(response); | |
var date= new Date(); | |
addrow(date, 'Success'); | |
} catch (error) { | |
addrow(date, 'Error'); | |
} | |
} | |
function addrow(date, status) { | |
var ss = SpreadsheetApp.getActiveSpreadsheet() | |
var sheetFun = ss.getSheetByName(sheet); | |
// sheet.insertRowAfter(sheet.getActiveCell().getRow()); | |
sheetFun.appendRow([date, status]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment