7 minutes reading time (1482 words)

Get to know the new Joomla! Task Scheduler

March-Task

Joomla’s Task Scheduler is a new addition to the core operating system of Joomla! 4.1. The Joomla development team added it to the core to help automate repetitive tasks that maybe you’d rather not do. You can use the Task Scheduler for a wide variety of maintenance and reporting tasks, and it runs on a Plugin system that can be added to and customised.

The task scheduler runs the task detailed in a Plugin via a cron job from within Joomla’s admin.

What’s a cron job? You ask. Let's dig into that now.

What’s a Cron Job?

Have you ever installed a Joomla Component only to find out you then need to set up a cron job for it to work completely on your hosting control panel? So have we.

A cron job is used to automate some part of the Components operation. This is usually a repetitive task that you’d prefer not to have to do! Because of this, many website owners forget to carry out these tasks. As a result, their website may not be as good as it could be.

Cron jobs are generally used to process email queues in newsletter systems, or to synchronise e-commerce orders with a delivery platform or to clean up cache and so on.

One problem of setting up a cron job to run on your server is knowing how to format the command line in the control panel for the cron job, so it triggers and runs as it should.

Warning: You need to have a good knowledge of Linux commands before you can use cron jobs effectively. Check your script with your hosting administrator before adding a cron job.

 

Do you know where your PHP folder is? What about the full URL to the cron file?

These are things the Component author can’t help you with and are invariably different between hosting companies.

A typical cron command line has three parts and may look something like this:

usr/local/bin/php /home/site1234/httpdocs/cli/cron.php

The first part is the route to your PHP folder, then there's an extra space, and finally the URL to the script that the cron will execute.

Then you need to decipher the timings that trigger the cron job. You need to decide how frequently it should run, and will your hosting provider even allow it to run that frequently, or at all? Some hosting companies put restrictions on their cron job schedules to help maintain resources across the server. This is almost always true if you host your website on a shared server.

Usually a VPS server or dedicated server won’t have these restrictions, as all the resources of the server are yours. But, these servers will cost you more to run than shared hosting, which is where many small business and personal websites live.

An experienced web developer understands this, but many people who want to run their own website often struggle with these settings. They then end up reaching out for support to help them get the Component working properly.

Joomla’s new task scheduler takes away some of this pain and aims to keep you on your website, in familiar surroundings. Rather than being up to your elbows in the nuts and bolts of your web server’s control panel.

Task Scheduler Overview

Now we know what a cron job is, let’s now take a look at some of Joomla’s Task Scheduler’s features, and some of the things that make this a great new addition to Joomla!’s core functions.

Task Scheduler allows you, the website owner, to create web-based cron jobs from an environment that you’re already familiar with, and comfortable working within.

Find the Task Scheduler

You can find the Task Scheduler in the System Dashboard, which is accessed from the main menu in the ‘Manage’ section.

Joomla Task Scheduler 1

Select A Task To Run

If you open the task Scheduler and select ‘New’, the currently installed task Plugins will be displayed. You can then select the task you’d like to schedule. By default Joomla 4.1 ships with 9 pre-installed task Plugins, some useful. Others are demo ideas.

If you have some extensions installed, for example Akeeba Backup, then their Task Schedule plugins will also be available to use.

 

Joomla Task Scheduler 2

Select Your Task Options

The options available from the Plugin’s new task menu simplify the cron job setup and allow you to select how you’d like the cron job to run. You set the frequency for the cron job to run in the Basic Fields, and if the cron job requires any extra settings, or options to run, you can set them in the Task Parameters section. The Advanced tab is where you can choose the priority for the cron job, over other tasks you may want to run. It’s also the place to tell the Plugin how you want to be notified that the cron job ran and was successful, or not.

 

Joomla Task Scheduler 4

 

Once you’ve set up the task, you can always go back and from the same settings sections, change how you want the task to run in the future.

Note:

It’s good practice to schedule tasks sensibly, especially on a shared server. Do you really need to set a task to resize a photo every minute when you only have one new article added weekly? If you have multiple tasks running, stagger the start times for the cron.

Example:

  • Task 1 runs every Monday at 11:30
  • Task 2 runs every hour, on the hour.
  • Task 3 runs every 4 hours and 18 minutes

Staggering the times you run the tasks also puts less demand on your server, which in turn keeps those server resources for your website, thus keeping your visitors happy using a fast website. Instead of one bogged down with unnecessary tasks running in the background.

You could also trigger the tasks to run when your website is less likely to receive many visitors. Running tasks during the evening, when most people are at home surfing the net, is probably unwise! Or, you can trigger the task to run manually any time you chose.

 

Joomla Task Scheduler 3

 

In the Task Scheduler’s options, you can choose how the tasks get triggered. Do you want them to run as specified in the tasks settings? Or, maybe it’s a task that needs to be run when someone visits a specific webpage. You can even set up a Web Cron URL with the Task ID that you want to run set as a query string (&ID=1). This means that you can run the task in question via an external trigger from a different website or app.

Many Joomla extension developers will include task plugins with their extensions to give you the option to automate certain tasks. For example, the popular Joomla backup extension Akeeba, already includes task Plugins in their Pro versions to set crons to run their backup processes.

Design Your Own Task Plugin

But, you’re not limited to what established extension developers give you. You can develop your own Plugins to trigger events you’d like to happen. The task schedule Plugins follow a simple Plugin syntax that allows the task scheduler to connect to them, and fire the Plugin’s commands on cue. Although you’ll have to have a solid understanding of PHP to write the necessary functions needed to action your task. Task Scheduler Plugins also give you the functionality to include Joomla’s new API functions, which open up a massive new level of functionality to your website.

Below is an example of Joomla's new Task Scheduler to base your next plugin on:

task scheduler plugin syntax

 

Task Scheduler Plugin Ideas

Apart from task plugins developed by Joomla component authors there are hundreds of other potential uses for Joomla’s new task scheduler. Limited only by your own imagination and need.

Here’s a list of 20 ideas to get you started.

  1. Resizing images uploaded by your authors so your website design remains consistent.
  2. Automatically regenerate your sitemap to reflect new articles.
  3. To ping Google to tell it you’ve published new content.
  4. To send you daily reports of website activity.
  5. To automate Component updates.
  6. To automate partial or full backups.
  7. To send out emails to your users/groups with data, you upload to your Google drive.
  8. To send you a new user report.
  9. To send you a list of new articles/posts/comments submitted.
  10. To send you daily logs from the website.
  11. Then to purge and delete those logs.
  12. To upload articles as social media posts to your social media channels.
  13. Change site or admin colour schemes light/dark mode automatically.
  14. Change website templates based on seasonal celebrations (Christmas, Easter, New Year, etc.)
  15. Send backup archives to cloud storage.
  16. Restart Node.js If you have an app that uses node.js on your server.
  17. Gather system health information and send via email.
  18. Send visitor data to superuser.
  19. Monitor and report hosting uptime/ downtime.
  20. Send pertinent new articles to various user groups.

What will you use Joomla!’s new Task Scheduler for?

1
Explore the Core - Accessibility Add-ons in Joomla...
Leadership Interviews: Benjamin Trenkle and Harald...
 

Comments 2

Already Registered? Login Here
Patrick on Saturday, 25 June 2022 01:57
Powerful stuff for Joomla — Thanks!

This is powerful, can wait playing with that. I want to tanks the Joomla Team for the great new features of Joomla.

0
This is powerful, can wait playing with that. I want to tanks the Joomla Team for the great new features of Joomla.
shoulders on Friday, 01 July 2022 19:10
An important feature that will be heavily used.

Nice article, Joomla has always need this feature.

The simple code put above is really handy and appreciated.

0
Nice article, Joomla has always need this feature. The simple code put above is really handy and appreciated.

By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/