Forum: Ruby on Rails Scheduling in backgroundrb not working

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ashwin K. (Guest)
on 2007-02-14 09:15
Hi ,
     How do i schedule a job that can send emails at intervals of time
     using backgroundrb and rails

     For testing When i hit the controller i'm able send the emails.
     but that is not i intend to do .....

     I want to use backgroundrb and rails in which i'll schedule a job
     for every 5 minutes/ 1 minute or so..... to send an email

     But when i write .yml file as given by the

     I'm unable to send emails ....... Infact my backgroundrb_server.log
     shows that scheduler is not even get triggered for every minute or

     I've no clue y the Scheduler is not working for every 1 minute or
     ........  Any help is appreciated !!!!

------------------------------------ backgroundrb.yml-----------------

:host: localhost
:port: 2000
:rails_env: development

    :class: :mailman_worker
    :job_key: :foo_name
    :worker_method: :send_emails_to_people
    :trigger_args: 0 */1 * * * * *

------------------------------------------my mailman_worker.rb --------

class MailmanWorker < BackgrounDRb::Worker::RailsBase

  def do_work(args)
    # This method is called in it's own new thread when you
    # call new worker. args is set to :args
    # Replace this with your code
    #'I am in do work')

  def send_emails_to_people

    @d_evals = User.find(:all,:conditions => ['id <= ?',3]

    for lop in @d_users'I am in loop')
      @user = User.find(:first, :conditions => [ 'id = ?',])



-------------------------------------Controller code-----

class TestffController < ApplicationController

  def a_pop
      MiddleMan.new_worker(:class => :mailman_worker, :job_key =>
      worker = MiddleMan.worker(:foo_name)



I am in do work
20070213-20:15:22 (29661) I am in send_emails_to_people
20070213-20:15:22 (29661) I am in loop
20070213-20:16:04 (29668) Starting WorkerLogger
20070213-20:16:05 (29669) In ResultsWorker
20070213-20:16:07 (29669) I am in do work
20070213-20:16:07 (29669) I am in send_emails_to_evaluators
20070213-20:16:07 (29669) I am in loop
20070213-20:16:13 (29669) I am in loop
20070213-20:16:19 (29669) I am in loop

20070214-13:40:47 (1672) Starting WorkerLogger
20070214-13:40:48 (1673) In ResultsWorker
20070214-13:41:32 (1673) I am in do work
20070214-13:41:32 (1673) I am in send_emails_to_people
20070214-13:41:33 (1673) I am in loop
20070214-13:41:39 (1673) I am in loop
20070214-13:41:46 (1673) I am in loop

0070214-13:45:48 (1694) Starting WorkerLogger
20070214-13:45:49 (1695) In ResultsWorker

 ------ Ashwin Kumar
Al E. (Guest)
on 2007-02-14 15:58
Ashwin Kumar wrote:

> :host: localhost
> :port: 2000
> :rails_env: development
> my_scheduler:
>     :class: :mailman_worker
>     :job_key: :foo_name
>     :worker_method: :send_emails_to_people
>     :trigger_args: 0 */1 * * * * *

My case is not quite the same, but as I recall, I wasn't able to make
*/1 work.

I use

  :trigger_args: 0 * * * * * *

To fire the worker once a minute.

I'm also not certain that :worker_method works. I use:

  :worker_method: :do_work

And call the "real" method from do_work.

>   def a_pop
>       MiddleMan.new_worker(:class => :mailman_worker, :job_key =>
> :foo_name)
>       worker = MiddleMan.worker(:foo_name)
>       worker.send_emails_to_people
>       worker.delete
>   end
> end

I don't do this, just set up the config files and
(nohup) script/backgroundrb start

(The nohup is required if starting it remotely, e.g., from capistrano,
to keep it from quitting when you exit the shell you started it from.)

I hope this helps. I've been using backgroundrb happily for several
months for DB backup, session expiration, and periodic emails.

--Al Evans
Joe P. (Guest)
on 2007-07-06 23:54
I can't seem to get backgrounDRb up and running.

Here is my "backgroundrb.yml" file ******************************
        job_key: mailing
        class: mailman_worker
Here is "mailman_worker.rb" *************************************
class MailmanWorker < BackgrounDRb::Rails

  repeat_every 5.minutes

  def do_work(args)
    ## This will send all the emails in the queued_mails table
    script/runner 'MailQueue.process' -e development #change
"production" to "development" or vice versa depending on what you're


It never seems to run.  What do I need to do to get it to start up
automatically, and then run every 5 minutes?

This topic is locked and can not be replied to.