To perform repetitive task we used to create a CRON job from our CPANEL, so that it will be executed after particular interval or at particular time of the day, everyday. But have you ever thought of using Google Apps Script to create your CRON job ?

Also There are so many online services are also available to create CRON job, some are free and some are paid.

Some of them require you to create an account then keep it updating regularly or if its paid, then you need to pay money to keep it running.

But today I am going to show you how you can create a simple CRON job by using Google Apps Script in a very short time.

Extract rss feed data or website content regularly in excel using google spreadsheet and google app script
Import RSS Feed in Excel Spreadsheet Daily using Google App Script

First login to your gmail account and then visit https://drive.google.com

If you want to create CRON JOB from Scratch then follow the following instructions.

Check the Video for creating a Scheduled Cron Job with Google Docs/Google Spreadsheet Apps Script.

How to create CRON using Google App Script

You can create a new spreadsheet.

Then go to “Tools -> Script Editor”

Google App Script Script Editor Menu Selection
Google App Script Script Editor Menu Selection

Then in a new window Script editor will be opened. Add following function to it.

/* * Google Apps Script for Creating a CRON Job
 * @prowebguru * 
https://www.prowebguru.com/ */ 
function executeCronJob() {
  var currentStatus = "";
  // Get Active Spreadsheet
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  // Access cell A1
  var dataRange = sheet.getRange("A1");
  // Get URL from cell A1
  var data = dataRange.getValues();
  
  var row = data[0];
  var websiteAddress = row[0];  // First column, now contains URL
  
  //delete previous entries
  sheet.deleteRows(1, 10);
  // Append results at the end
  sheet.appendRow(['=IMPORTFEED("https://www.prowebguru.com/feed/","items",true,10)']);
  // Make sure the cell is updated right away in case the script is interrupted
  SpreadsheetApp.flush();
}

Save the file by giving some name.

Now click on “Play” or “Run” button to execute the script. As its a first time execution, it will ask you for some permissions. Give permissions to execute the script. Following popups will be shown to you to allow script execution.

Google app script permissions to execute script
Google App Script Review Permissions Dialog, click “Review Permissions”
Select your email / account to proceed
Select your email / account to proceed
Click on "Advanced" and then click on "Go to cronjob"
Click on “Advanced” and then click on “Go to cronjob”
Finally click on "Allow" to given required permissions
Finally click on “Allow” to given required permissions

Next Click on “Edit->Current Script’s Triggers”

It will open another window. Click on “Add Trigger”.

Google App Script execute function at specified date and time
Google App Script execute function at specified date and time
Google App Script cron Trigger Time-driven, every minute, hourly, daily, weekly
Google App Script cron Trigger Time-driven, every minute, hourly, daily, weekly

Select appropriate options from the dropdown and click save.
Congratulations ! You have just created a CRON Job Schedule with Google Apps Script and Google Docs Spreadsheet.