Created
July 4, 2020 16:48
-
-
Save arshinalbab/81a31ef23b4203c059daef66433fffe3 to your computer and use it in GitHub Desktop.
Heroku Cron 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
| 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