## Task Queue

The Task Queue page allows system administrators to view, run, delete, and debug tasks that run in the background: search and recommender database indexing, saved search mailings, and plugin-related tasks.

Tasks are automatically run periodically as determined by the Maximum Execution Time and Maximum Simultaneous Background Tasks settings. Tasks run in the background by default. CWIS will keep running after returning a page to a web browser if there are tasks to execute and no tasks currently executing.

### Task Descriptions

Running tasks are those that are currently executing and queued tasks are those that are queued for execution when the running tasks finish executing.

Running tasks can become orphaned tasks when they take too long to execute, as determined by the Maximum Execution Time setting, or when they cause an error. Sometimes tasks become orphaned because of temporary slowdowns and it's often safe to requeue them. Tasks that repeatedly appear in the orphaned task list might be causing an error, and hovering over an orphaned task with the mouse for a few seconds will display an error message if one exists. Contact the CWIS support team if a task produces an error.

A queued task can be run in the foreground (so it executes before the page is returned to the web browser) by clicking the ``Run`` button associated with it. Executing a task in the foreground can make the page load slowly if the task takes a lot of time to execute. A queued task can be deleted by clicking the the ``Del`` button associated with it. An orphaned task can be requeued by clicking the ``Que`` button associated with it, in addition to being able to be deleted or run in the foreground.

Caution should be used when deleting tasks because some of them can cause CWIS to get into an inconsistent state if they do not execute. Deleting a task that indexes a resource record in the search engine database after an update to its metadata, for example, will cause the old index to be used or none at all if it has never been indexed.

### Automatic Task Execution

The process that executes queued tasks is triggered by page views and will not be able to run all of its tasks as scheduled if there are insufficient visits to the site. System administrators can leave the Task Queue page open to overcome this limitation. The page is set to reload every 30 seconds, ensuring that enough page views will occur to drive task execution.

System administrators may also use a program, such as cron, to fetch the page on a schedule. This is an advanced topic and might require an IT or similarly-technical team member to implement.

Automatic task execution can be disabled by unchecking the Automatic Task Execution Enabled checkbox on the Task Queue page. In this scenario, all tasks will have to be executed manually by clicking the ``Run`` button associated with them. Since background tasks are used for vital parts of CWIS like search database updates, automatic task execution should only be disabled to briefly pause execution or to debug a problem.

### See Also

- Plugins