Remove all Gearman jobs from the Gearman Job Server Remove all Gearman jobs from the Gearman Job Server php php

Remove all Gearman jobs from the Gearman Job Server


Removing all jobs of single type

Use the following command (just replace FUNCTION_NAME):

gearman -n -w -f FUNCTION_NAME > /dev/null

To remove only n number of jobs add -c n param, i.e. to remove 20 jobs:

gearman -c 20 -n -w -f FUNCTION_NAME > /dev/null


Removing all jobs from server

If you want to remove all jobs, run the following loop:

for MATCH in $(echo status | nc 127.0.0.1 4730 | grep -v \\. |  grep -Pv '^[^\t]+\t0\t' | cut -s -f 1-2 --output-delimiter=\,); do     gearman -n -w -f ${MATCH%\,*} -c ${MATCH#*\,} > /dev/null;done

Replace 127.0.0.1 4730 with your gearmand server address and port.

ps: removing jobs from persistent storage (i.e. sqlite) will not remove them from gearmand until it is restarted (because gearmand process has in-memory cache)


Using Persisten Queues it's easy, just truncate the queue table.