I am looking to setup a queue system to upload large files (~150MB). For specific reasons we decided to do this using SFTP (phpseclib). After some research I came to the conclusion that I would probably need something like a work queue. I decided to go with Beanstalkd since there was a drupal module for it.

I have managed to get a Beanstalkd server running and add items to the queue. But now I'm kind of confused as to how I would need to execute a specific script.

Can anyone help with this particular part of getting beanstalkd queue items to run in a non-blocking way?

Do I need to maybe write a shell script to run a php cli or am I looking at it all wrong?

2 Answers 2


I managed to figure it out.

Using hook_cron_queue_info, it is possible to define worker callbacks for queue items.

I then wrote the sftp upload script in the worker callback and then run the runqueue.sh script that comes with the drupal beanstalkd module to listen for ready queue items.


In case anyone stumbles on this question looking for a Drupal 8 solution, the process changed: hook_cron_queue_info() got renamed to hook_queue_info(), then replaced by worker plugins. So, in 8.0.0-rc2 and later, you need to create a worker class as a QueueWorker plugin, placing it in your module's src/Plugin/QueueWorker directory, and adding it the needed annotations, like this example taken from the SampleWorker example provided in the Beanstalkd module:

 * Pretend to perform some work.
 * @QueueWorker(
 *   id = "beanstalkd_example",
 *   title = @Translation("Beanstalkd example worker"),
 *   cron = {"time" = 60}
 * )
class SampleWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
// ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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