The servers_queue Script

Valid for versions 82 through the latest version

Version:

82


Last modified: February 22, 2024

Overview

This script allows you to manage the task queue system. The task queue system allows cPanel & WHM to execute tasks as a background process to improve server response time. You can use WHM’s Task Queue Monitor interface (WHM » Home » Server Status » Task Queue Monitor) to view tasks in real time.

Warning:
  • This script is for advanced users only. Modifying a task queue process may render your server nonfunctional.
  • You should always use WebPros International, LLC’s documented API functions for the appropriate task.
  • The name of modules monitored by the task queue system are subject to change.

Note:
  • The queueprocd daemon in the /usr/local/cpanel/libexec directory periodically processes the task queue. The cPanel & WHM startup process starts this daemon. To restart it, use the /usr/local/cpanel/scripts/restartsrv_queueprocd script.
  • The chksrvd daemon monitors the queueprocd daemon.

Run the script

To run this script on the command line, use the following format:

/usr/local/cpanel/bin/servers_queue [options]

Options

Use the following options with this script:

Options Description Example
queue Use this option to add a subprocess to the task queue. When you queue a task, the system returns a unique task ID. For example:

TQ:TaskQueue-Scheduler:5912

In this example, 5912 is the assigned task ID.
/usr/local/cpanel/bin/servers_queue queue apache_restart
unqueue Use this option to dequeue a task from the task queue.
Note:
When you use this option, you must provide the task’s unique task ID with it. The system outputs this unique ID when you queue a task. You can also locate the task ID number in the /var/cpanel/taskqueue/servers_queue.json file.
/usr/local/cpanel/bin/servers_queue unqueue TQ:TaskQueue-Scheduler:5912
schedule Use this option to specify a wait time, in seconds, and add a subprocess to the task queue. The task queue will not process the command until after the wait time passes. /usr/local/cpanel/bin/servers_queue schedule 600 apache_restart
unschedule                             Use this option to remove a task from the task queue.
Note:
When you use this option, you must provide the task’s unique task ID with it. The system outputs this unique ID when you queue a task. You can also locate the task ID number in the /var/cpanel/taskqueue/servers_queue.json file.
/usr/local/cpanel/bin/servers_queue unschedule TQ:TaskQueue-Scheduler:5912
run Use this option to perform a synchronous flush of the task queue. This runs all the task queue’s queued jobs immediately. This argument does not return output. /usr/local/cpanel/bin/servers_queue run
help Use this option to display usage information for the script. /usr/local/cpanel/bin/servers_queue help

Additional Documentation