#TIL : Gearman bash worker and client

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 :

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

Create a worker bash script

worker.sh

1
2
3
4
#!/bin/bash

echo $1
echo $2

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

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

Sending job

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

Sending background job

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