Providing an easy to follow installation guide, and working samples for client, job server and workers is the purpose of this repo. gearmand (written in C) and the PECL extension will be usedPecl php extensions
PHP Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


At the time of this writing

gearman job server (libgearman) 1.1.x or later (part of the 1.2 Series as described in the series and milestones is considered unstable and pecl client 1.1.x requires modules from libgearman 1.1.

Therefore the suggested installation is gearman job server 1.0.6 and pecl 1.0.3

This document describes the installation process and working samples for client, job server and workers for [Gearman] 1


Example 01_helloworld

start a client, start a worker (not necessarily in this order) and see the job get done.

Example 02_async

start a client, start a worker and see the job get done. The client script ends without waiting for the job to finish (work runs in background)

Example 03_GearmanManager

Spawn workers with [Gearman Manager] 3 (not maintained)

Example 04_Supervisord

Spawn workers with [Supervisord] 2

Example 05_graceful_restart

Gracefully restart gearman workers

  • Ensure that workers don't drop started but unfinished jobs.
  • terminate the worker based on number of jobs completed and maximum Duration

Monitoring: Gearman Monitor web application [Gearman Monitor] 4

Software Dependencies

For Client and Server

sudo apt-get -y install libgearman-dev libevent-dev

For Server

sudo apt-get -y install libboost-all-dev cloog-ppl

Installing Job Server

From sources Install 1.0.6 (recommended)

curl -L > gearmand-1.0.6.tar.gz
tar xzf gearmand-1.0.6.tar.gz &&
cd gearmand-1.0.6 &&
./configure &&
make &&
sudo make install &&
cd ../ &&
rm -rf gearmand-1.0.6 &&
rm gearmand-1.0.6.tar.gz

Setup Service

Switch to this directory cd setup

sudo cp init.d-gearman-job-server /etc/init.d/gearman-job-server
sudo /etc/init.d/gearman-job-server start

Install Dev version from 1.2 series

sudo apt-get install python-software-properties sudo add-apt-repository ppa:gearman-developers/ppa sudo apt-get update sudo apt-get install gearman-job-server gearman-tools

Setup service from dev

sudo /etc/init.d-gearman-job-server start

Install default from packages

the problem with this approach is that Ubuntu has a very old version of gearmand 0.27 or 0.33 depending on the distribution.

sudo apt-get install gearman-job-server

Job Server Status Changes


sudo service gearman-job-server start


sudo service gearman-job-server start

check status

sudo service gearman-job-server status

Job Server Process


gearmand -d -L -l  /var/log/gearmand.log


(echo shutdown ; sleep 0.1) | netcat 4730 -w 1

check status in processes:

lsof -i -P | grep gearmand

check status should output:

gearmand 26501 root 8u IPv4 69854 0t0 TCP *:4730 (LISTEN)
gearmand 26501 root 9u IPv6 69855 0t0 TCP *:4730 (LISTEN)

check status querying gearman's Administrative Protocol

check status

 (echo status; sleep 0.1) | netcat 4730 -w 1

check workers

  (echo workers; sleep 0.1) | netcat 4730 -w 1

Installing gearman PHP Extension (PECL)

from PECL

sudo pecl uninstall gearman &&
sudo pecl install gearman-1.0.3

from sources

  1. download from PECL

    curl > pecl-gearman.latest.tgz

NOTE: if you plan to use GearmanManager pecl gearman 0.81 is recommended instead of 1.0.2 due to a bug as described here. No need to worry about downgrading. Installing 0.8.1 will overwrite previous installation.

curl > pecl-gearman.latest.tgz
  1. install

    tar xzf pecl-gearman.latest.tgz cd gearman-X.Y phpize ./configure make make install

  2. add php extension

in php.ini add extension="" or alternatively touch gearman.ini in conf.d directory adding this line:extension=""

  1. validate installation

execute this php command from your environment (apache, cli, php -a) print gearman_version() . "\n";


Gearman Monitor

Provides a web interface to display worker, server and queue status. Cloned from


  1. Prerequisite pear Net_Gearman (at the time of the writing 0.2.3 alpha)
   pear install Net_Gearman-0.2.3
  1. git clone

  2. Modify /etc/apache2/sites-available/

    <VirtualHost *:80>
	ServerName gearman-monitor.local
	DocumentRoot <path-to-project>/Gearman-Monitor
  1. Setup Gearmonitor on Apache (modify /etc/hosts) gearman-monitor.local
  1. modify _config.php with the server info
    $cfgServers[$i]['address'] = '';
    $cfgServers[$i]['name'] = 'Gearman server 1';
  1. Restart Apache
   sudo service apache2 restart
  1. browse the site

gearman administrator script

monitoring/administator.php a command line monitoring tool

Gearman Manager

Gearman Manager will be tested at a later step

Supervisord With Gearman

Supervisor provides monitoring and controlling of processes on Unix-like systems Here an installation script is provided and instructions on how to manage gearman workers with Supervisord