#TIL : Gearman bash worker and client


15 Jun 2017 / by KhanhIceTea

Gearman is a awesome job queue service that helps you scale your system. In smaller context, it can help us to run a background woker for minor tasks like backup data, cleaning system.

Install :

$ sudo apt install gearman-job-server gearman-tools

Create a worker bash script

worker.sh

#!/bin/bash

echo $1
echo $2

Run worker, -w means run as worker mode , -f test means function name will be test

$ chmod +x worker.sh
$ gearman -w -f test xargs ./worker.sh

Sending job

$ gearman -f test "hello" "hogehoge"

Sending background job

$ gearman -b -f test "hello" "hogehoge"

Sound good ?