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.
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 ScriptYou can create a new spreadsheet.
Then go to "Tools -> Script Editor"
Google App Script Script Editor Menu SelectionThen in a new window Script editor will be opened. Add following function to it.
/* * Google Apps Script for Creating a CRON Job * @prowebguru * http://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("http://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 Review Permissions Dialog, click "Review Permissions"Select your email / account to proceedClick on "Advanced" and then click on "Go to cronjob"Google App Script execute function at specified date and timeGoogle App Script cron Trigger Time-driven, every minute, hourly, daily, weekly Finally click on "Allow" to given required permissionsNext Click on "Edit->Current Script's Triggers"
It will open another window. Click on "Add Trigger".
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.