2

I've seen the xargs method of passing arguments into gearman, but how do I just get my script to take STDIN as the input for my gearman worker instead?

The use case here is that I have a bunch of IDs that I'd like to simply fire off as this.

gearman -f job 123456
gearman -f job 123457
gearman -f job 123458
gearman -f job 123459
gearman -f job 123460

If I could do that, then iterating over a list of id numbers would be really easy.

0

If you script already uses $1 as your input and you simply want to set that to default to stdin if $1 isn't set you can set you variable in this way.

# Set id to first argument or stdin if that is blank
id=${1:-$(cat -)}

Then when you startup the worker simply do

gearman -w -f job script.sh

Then to send a task to the worker that sets var to 123456 simply do this

gearman -f job 123456

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.