google

WordPress Alternate Cron Job Using Google App Script

Have you ever wondered that you can use Google App Script to create an alternate cron for wordpress wp-cron.php ? Most of the websites have issues with running wp-cron.php properly.

Wanna know ? Then read on….

Lots of website developers or bloggers face issues with WordPress cron. If your website has less number of visitors then your wordpress cron may not run.

wp-cron.php is ran everytime someone visits a page of your website. So if you have scheduled a blog post to be published at particular time and if there is no visit at that time, then probably your scheduled post publishing time is gonna miss.

So alternate solution to WordPress cron not executing properly is, use external service. And call your wp-cron.php file.

WordPress Create Alternate Virtual Cron Using Google App Script

You will find lots of services which offer you to create a cron job. Some of them are free, some are paid. And might have different limitations.

So, today I am going to show you how you can create your own Cron for wordpress, and execute your wp-cron.php file as per your choice. eg. Run wordpress wp-cron.php file every minute or every 5 minutes, hourly, daily etc.

If you are facing issues with WordPress Cron job not working, then here is alternate solution to make WordPress Cron working without paying any money.

We are going to use Google App Script for creating a cron schedule. Its very easy to use Google Scheduled Triggers to execute jobs regularly. It can used for executing recurring jobs eg. fetching data from, trigger a page url etc.

If you are creating your first Google App Script then visit my previous blog post about, how you can use Google App Script for fetching contents from RSS feed and schedule that as Cron job. I have explained complete process with screenshots for first timers.

You can always watch video below, it has all steps.

Create a free WordPress cron using Google App Script, Create Cron Job for WordPress wp-cron.php using Google App Script

Following is our Google App Script for executing wordpress wp-cron.php url as cron.

/*
Google Apps Script for Creating a free WordPress wp-cron.php CRON Job
@prowebguru 
https://www.prowebguru.com/ 
*/
function executeWordpressCronJob() {
  // 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 date = new Date();
  
  var row = data[0];
  var websiteAddress = row[0];  // First column, now contains URL
  var response;
  try {
    response = UrlFetchApp.fetch(websiteAddress);
    if(response.getResponseCode() == 200) {
      sheet.appendRow([date,'Successful']);
    } else {
      sheet.appendRow([date,'Issue']);
    }
  } catch(e) {
    if(e.toString().indexOf('returned code 404') > -1)
      sheet.appendRow([date,'404 Url not found']);
    else
      sheet.appendRow([date,e]);
  }
  SpreadsheetApp.flush();
}

Steps to create a WordPress Cron using Google Spreadsheet & create a Google App Script

  • For creating a cron job using Google App Script, you need to visit Google Drive.
  • Then create a new Google Spreadsheet.
  • Save sheet by giving a proper name.
  • In the first cell, mention complete url of wp-cron.php with domain name.
  • Then goto Tools menu and click on “Script Editor”.
  • Save script by giving a proper name.
  • Copy above script in the code section of the script.
  • Save script.
  • Then click on Edit menu and click on “Current project’s triggers”.
  • A new page is opened, click on “Add Trigger”.
  • In the section “Choose which function to run”, by default our function “executeWordpressCronJob” will be selected as we have only one function.
  • “Choose which deployment should run” will be as it is, “Head”.
  • In the “Select event source” section, select “Time-driven”.
  • Next in the “Select type of time based trigger” section, select “Minutes timer”.
  • Now in the “Select minute interval” section, select “Every minute”.
  • Lastly the “Failure notification settings”, you can select as per your choice. So this notification will send you an email, if your script fails for some reason.
  • Once this is done, click on “Save”.

Its done. You have created your WordPress wp-cron.php cron job using Google Spreadsheet and Google App Script. Our code also has capability to keep a record of every execution. If you don’t want to keep a track of every execution, then just remove or comment lines having “sheet.appendRow”.

You can also extend this script to run cron job for multiple wordpress sites/urls. Or read data from list of urls and then process it.

Is it useful to you ? Did it solve your issues ?

ProWebGuru

Mostly I write about technology related stuff on https://www.prowebguru.com Recently I have started making videos also. Mostly blog posts & videos are related to technology, programming and learning some new tips and tricks related to windows, wordpress, google app script, technical, programming, javascript, jquery and other coding related stuff. Youtube channel - https://www.youtube.com/user/prowebguru

Recent Posts

GPT 5.4: Powerful AI Breakthrough – 7 Game-Changing Features, Launch Date & Full Guide

GPT 5.4: The Next-Generation AI Model Transforming Reasoning, Coding, and Productivity Artificial Intelligence is evolving…

1 day ago

GPT‑5.3 Instant Explained: Faster, Smarter & Fewer Refusals

GPT-5.3 Instant is OpenAI's latest ChatGPT model update, prioritizing smoother conversations, fewer refusals, and higher…

2 days ago

Free Perplexity Pro for Airtel Customers: Unlock Advanced AI Assistance at No Cost!

Are you tired of scrolling endlessly through Google results trying to find clear, trustworthy answers?…

4 months ago

Unlocking Collaborative Coding with GitHub Copilot Spaces

In recent years, the process of software development has rapidly evolved—developers demand smarter tools and…

4 months ago

ChatGPT Go Now Free in India: Opening Doors to Advanced AI Capabilities

India has emerged as one of the fastest-growing and most significant markets in the global…

4 months ago

AgentKit by OpenAI: Redefining the Future of AI Agent Development

On October 6, 2025, OpenAI unveiled AgentKit, a unified suite of tools designed to help developers and…

5 months ago

This website uses cookies.