What are cron jobs?

“What are cron jobs?” Very good question, which the experts in web hosting will break into two sub-questions and answer immediately:

  • What is a cron job?
  • What is WP-CRON?

What are cron jobs

At its core, a cron functions as software that programs various time-based processes. Manages various tasks that must be done on a regular basis and at a specific time. For example, suppose you have a WordPress blog and on the main page you want the weather forecast to appear in a prominent place on a daily basis.

What should you do? Every day, you should look for the weather forecast yourself and then update your blog. Or you could hire someone to log in to your blog every morning, find the current weather forecast, and update the widget accordingly.

It makes sense;  Obviously not.

A more efficient and inexpensive option would be to have a program that “runs” every morning (at a time of your choice), “talks” with an API to get the latest weather forecast and updates your blog database without human hand needed to intervene.

The program that undertakes to “run” your software that concerns the forecast of the weather on a daily basis and at a specific time, is CRON (or Cron Job). Its name, as you have probably already understood, is of Greek origin and is related to time as these are essentially processes that are determined within (and based on) time.

Today, most systems incorporate some kind of analog technology – even an iPhone with the Shortcuts app can send a specific SMS every day at a specific time and recipient. The cron, then, is always run in the background and every minute checks the crontab (or cron table) to see if there is anything to be done. If not, he falls asleep again.

At this point, think of crontab as a calendar that has information about when and which program to run. Each extra line in this file means a different task. Most web hosting companies, such as MultiHosting, give you access to this system.

What is WP-CRON?

WordPress, in turn, does things a little differently – we refer to WordPress because, for better or worse, it is the most popular web design software. Because many plugin developers needed the ability to schedule various tasks to occur at regular intervals, and because many webmasters ignored the crontab site and much more how to modify it, WordPress reinvented cron jobs.

At its core, WP-CRON works like a traditional cron in the sense that a developer can schedule a task on a regular basis. However, unlike a traditional cron, WordPress does not have a program running in the background on your server.

To make scheduling work in WordPress, WP-CRON works as a process that runs every time a specific page runs. On popular websites, this works just fine. However, if your site does not have many visitors, a task that is scheduled for example at 04:00 in the morning, can   be performed at 07:24 if in the meantime the site has no visitors.

The truth is that in some cases this may be ok while in other cases it may be a problem. Therefore, if the tasks you want to run automatically must be “running” at the time you set them up, then WP-CRON is not something you would want to use. Conversely, if the tasks you have scheduled can be performed “close to the time” you have scheduled, then WP-CRON is especially useful for you.

I repeat: the traffic of your website plays an important role in all this.

What are your alternatives?

If the tasks you want to perform automatically are highly critical and you want them to be executed on time, and you are in the rare but awkward position of your provider not offering access to the system cron, you have two options. Initially, the simplest solution is to change providers. You can always come to a modern web hosting company , such as MyIP, which will offer you the obvious: the access you need.

If for some reason this is either not possible or desirable, there are various services, some free and some paid, that do exactly what you want: to act as cron services. They basically run a system themselves that usually allows you to schedule a task through a web interface. In this case, a program such as curl or wget will be used which will “call” the URL on your website to perform the task of your choice.

Most plugins that need cron will also give you the appropriate URL to call in case you want to use a third party service. All you have to do is copy and paste the URL, select the runtime, and that’s it.

The usefulness of cron jobs

Once you understand the way you will work on the tasks, you will find that the system of cron jobs is a very useful tool for which you will find more and more uses. If you have plugins installed in your WordPress, I can almost guarantee that your page has wp-cron jobs running.  In case you want to satisfy your curiosity, you can just visit the WordPress plugin repository and search for the term cron.

There are several plugins that will show you all the WP-CRON activity on your site. Be careful, though. Plugins set these tasks for specific reasons. If you decide you do not like someone and delete it, the plugin that relies on this automated process may stop working.

See more services about web hosting:

What are cron jobs?