Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save arshinalbab/81a31ef23b4203c059daef66433fffe3 to your computer and use it in GitHub Desktop.

Select an option

Save arshinalbab/81a31ef23b4203c059daef66433fffe3 to your computer and use it in GitHub Desktop.
Heroku Cron Script
function myFunction() {
var d = new Date();
var hours = d.getHours();
var currentTime = d.toLocaleDateString();
var counter = SpreadsheetApp.getActiveSheet().getRange('B1').getValues();
// check if the current time is between 6am to 6pm. If yes, it will visit my heroku app, and then log this activity on the accompanying Google Sheet at Column A
if (hours >= 1 && hours <= 24) {
// Visit the specified
var response = UrlFetchApp.fetch("https://bitpiller-craft-prod.herokuapp.com/");
SpreadsheetApp.getActiveSheet().getRange('A1').setValue('Visted at ' + currentTime + " " + hours + "h");
SpreadsheetApp.getActiveSheet().getRange('B1').setValue(Number(counter) + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment