Running Tasks

From the GUI

On the Dashboard > System & Settings > Automation > Tasks page, you’ll see a list of all tasks installed in your site.

Tasks 1

To run a task from this interface, first choose a task a by clicking on the radio button next to it. Here, let’s select “Reindex Content” to reindex all the pages in our site.

Once we select “Reindex Content”, any input variables that this task makes available are available beneath the task grid:

Tasks 2 Options

Using these options, we can determine whether we want to clear the index prior to re-indexing all the entries, whether we want to fully rebuild the underlying database table, reindex just a subset of pages, and which object type we want to reindex (pages).

Once we’re happy with the choices we’ve selected, we can click “Run Task” and the task will execute. This will redirect us to the Task Activity page:

Tasks RunningSince the “Reindex Content” task is a batch processing task, it gathers all pages into a batch and executes them asynchronously. Other tasks operate differently. For example, the “Clear Cache” task is a synchronous task – meaning it executes and the user will wait while it executes. When it’s done it gives immediately feedback.

Tasks Cache Cleared

The “Generate Sitemap” command is an asynchronous, non-batched task: that means it operates in the background, without tying up the user and making them wait – but it only executes a single command.

Here we have our “Generate Sitemap” task waiting in the task queue for our “Reindex Content” task to complete:

Tasks sitemapxml

From the Command Line

Any task that’s installed can be executed from the Dashboard tasks interface, and from the command line. Here’s our list of tasks from the command line:

First, type concrete/bin/concrete from within your site’s root directly on the command line. You should see a long list of commands available, with tasks toward the end:

Tasks CLI LIst

This list of commands is dynamically generated from the tasks installed in the site. To get help for any of the commands you can add the --help option while calling the command. 

Typing concrete/bin/concrete task:reindex-content --help yields:

Tasks CLI Reindex

See the boolean options for “clear”, “rebuild”, the numerical option for “after” and the required argument for “object”? The same options available for configuring a task in the GUI are also available in the command line. This is one of the major advantages to Tasks when compared to Jobs in previous versions of Concrete CMS.

Let’s reindex our site’s page content from the command line. Let’s also rebuild the index entirely, and clear it out to ensure it’s fully up to date. 

concrete/bin/concrete task:reindex-content --clear --rebuild pages

Tasks CLI Index OutputThere’s lots of information available about the process in question, including what attributes are being rebuilt, which pages are being reindexed and when, etc…

GUI and Console Unification

In case it’s not clear from these examples, tasks are fully unified across the GUI and console. The same options available to the GUI are available in the console, by design. The same output that is shown on the console will also be placed in the task logs (more on this later.) Finally, the console and the GUI fully coexist and can work together.

For example, Let’s start a reindex content task from the GUI:

Tasks Running Activity And start a rescan files task from the command line:

Tasks Unification CLIIf we reload the Activity dashboard screen we can watch our rescan files task happen simultaneously with the reindex content task. Statuses will be updated in realtime. 

Tasks Running Activity 2Note: Tasks run from the console are run immediately when requested, and run synchronously, even if they operate in batches. Tasks started from the Dashboard that are batch processes will be run asynchronously in batches. That means if you were to start the “Reindex Content” and “Rescan Files” tasks from the Dashboard, the second task would wait to start until the items in the first task were processed. But since we started our “Rescan Files” task from the console, our operation takes place at the same time.