It''s sending e-mail every hour, but I changed to sleep for a day, but keep send the e-mail by hour. I don''t know what to do to send daily. Could somebody help me? thanks ############ # mailer.rb ############### #!/usr/bin/env ruby # You might want to change this ENV["RAILS_ENV"] ||= "production" require File.dirname(__FILE__) + "/../../config/environment" $running = true Signal.trap("TERM") do $running = false end while($running) do Notifier.deliver_report_daily #ActiveRecord::Base.logger.info "This daemon is still running at #{Time.now}.\n" sleep 86400 end ########### # deploy.rb ############ desc "Stop daemons before deploying" task :before_deploy do run "#{current_path}/script/daemons stop" end desc "Start daemons after deploying" task :after_deploy do run "#{current_path}/script/daemons start" end -- Posted via http://www.ruby-forum.com/.
Penelope West wrote:> It''s sending e-mail every hour, but I changed to sleep for a day, but > keep send the e-mail by hour. I don''t know what to do to send daily. > Could somebody help me? > > > thanks > ############ > # mailer.rb > ############### > #!/usr/bin/env ruby > > > # You might want to change this > ENV["RAILS_ENV"] ||= "production" > > require File.dirname(__FILE__) + "/../../config/environment" > > $running = true > Signal.trap("TERM") do > $running = false > end > > while($running) do > > Notifier.deliver_report_daily > #ActiveRecord::Base.logger.info "This daemon is still running at > #{Time.now}.\n" > > sleep 86400 > > end > > ########### > # deploy.rb > ############ > desc "Stop daemons before deploying" > task :before_deploy do > run "#{current_path}/script/daemons stop" > end > > desc "Start daemons after deploying" > task :after_deploy do > run "#{current_path}/script/daemons start" > endI certainly would not use a long running daemon for this purpose. You should look into using cron and script/runner to execute the task daily. 0 8 * * * /path/to/rails/app/script/runner -e production "Notifier.deliver_report_daily" This will deliver your daily report each day at 8 am. Best, Michael Guterl -- Posted via http://www.ruby-forum.com/.
if you had initially set it to sending every hour and then changed it to every day in between, then u may have to re-start the daemon.. did you do that? but i second Michael.. you should be using a cron for this. On Aug 3, 7:47 am, Michael Guterl <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Penelope West wrote: > > It''s sending e-mail every hour, but I changed to sleep for a day, but > > keep send the e-mail by hour. I don''t know what to do to send daily. > > Could somebody help me? > > > thanks > > ############ > > # mailer.rb > > ############### > > #!/usr/bin/env ruby > > > # You might want to change this > > ENV["RAILS_ENV"] ||= "production" > > > require File.dirname(__FILE__) + "/../../config/environment" > > > $running = true > > Signal.trap("TERM") do > > $running = false > > end > > > while($running) do > > > Notifier.deliver_report_daily > > #ActiveRecord::Base.logger.info "This daemon is still running at > > #{Time.now}.\n" > > > sleep 86400 > > > end > > > ########### > > # deploy.rb > > ############ > > desc "Stop daemons before deploying" > > task :before_deploy do > > run "#{current_path}/script/daemons stop" > > end > > > desc "Start daemons after deploying" > > task :after_deploy do > > run "#{current_path}/script/daemons start" > > end > > I certainly would not use a long running daemon for this purpose. You > should look into using cron and script/runner to execute the task daily. > > 0 8 * * * /path/to/rails/app/script/runner -e production > "Notifier.deliver_report_daily" > > This will deliver your daily report each day at 8 am. > > Best, > Michael Guterl > -- > Posted viahttp://www.ruby-forum.com/.
Yes, I restart, but nothing change. Continuing send the old e-mail. Send one time the new, but after every hour send the old. Do you know what I have to do? Thanks On Aug 3, 1:16 am, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> if you had initially set it to sending every hour and then changed it > to every day in between, then u may have to re-start the daemon.. did > you do that? > but i second Michael.. you should be using a cron for this. > > On Aug 3, 7:47 am, Michael Guterl <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Penelope West wrote: > > > It''s sending e-mail every hour, but I changed to sleep for a day, but > > > keep send the e-mail by hour. I don''t know what to do to send daily. > > > Could somebody help me? > > > > thanks > > > ############ > > > # mailer.rb > > > ############### > > > #!/usr/bin/env ruby > > > > # You might want to change this > > > ENV["RAILS_ENV"] ||= "production" > > > > require File.dirname(__FILE__) + "/../../config/environment" > > > > $running = true > > > Signal.trap("TERM") do > > > $running = false > > > end > > > > while($running) do > > > > Notifier.deliver_report_daily > > > #ActiveRecord::Base.logger.info "This daemon is still running at > > > #{Time.now}.\n" > > > > sleep 86400 > > > > end > > > > ########### > > > # deploy.rb > > > ############ > > > desc "Stop daemons before deploying" > > > task :before_deploy do > > > run "#{current_path}/script/daemons stop" > > > end > > > > desc "Start daemons after deploying" > > > task :after_deploy do > > > run "#{current_path}/script/daemons start" > > > end > > > I certainly would not use a long running daemon for this purpose. You > > should look into using cron and script/runner to execute the task daily. > > > 0 8 * * * /path/to/rails/app/script/runner -e production > > "Notifier.deliver_report_daily" > > > This will deliver your daily report each day at 8 am. > > > Best, > > Michael Guterl > > -- > > Posted viahttp://www.ruby-forum.com/. > >
Use the delayed_job plugin if you find it hard to tweak scripts to your taste. On Aug 4, 1:19 am, Penelope <ludmor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes, I restart, but nothing change. Continuing send the old e-mail. > Send one time the new, but after every hour send the old. > > Do you know what I have to do? > Thanks > > On Aug 3, 1:16 am, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > if you had initially set it to sending every hour and then changed it > > to every day in between, then u may have to re-start the daemon.. did > > you do that? > > but i second Michael.. you should be using a cron for this. > > > On Aug 3, 7:47 am, Michael Guterl <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > > Penelope West wrote: > > > > It''s sending e-mail every hour, but I changed to sleep for a day, but > > > > keep send the e-mail by hour. I don''t know what to do to send daily. > > > > Could somebody help me? > > > > > thanks > > > > ############ > > > > # mailer.rb > > > > ############### > > > > #!/usr/bin/env ruby > > > > > # You might want to change this > > > > ENV["RAILS_ENV"] ||= "production" > > > > > require File.dirname(__FILE__) + "/../../config/environment" > > > > > $running = true > > > > Signal.trap("TERM") do > > > > $running = false > > > > end > > > > > while($running) do > > > > > Notifier.deliver_report_daily > > > > #ActiveRecord::Base.logger.info "This daemon is still running at > > > > #{Time.now}.\n" > > > > > sleep 86400 > > > > > end > > > > > ########### > > > > # deploy.rb > > > > ############ > > > > desc "Stop daemons before deploying" > > > > task :before_deploy do > > > > run "#{current_path}/script/daemons stop" > > > > end > > > > > desc "Start daemons after deploying" > > > > task :after_deploy do > > > > run "#{current_path}/script/daemons start" > > > > end > > > > I certainly would not use a long running daemon for this purpose. You > > > should look into using cron and script/runner to execute the task daily. > > > > 0 8 * * * /path/to/rails/app/script/runner -e production > > > "Notifier.deliver_report_daily" > > > > This will deliver your daily report each day at 8 am. > > > > Best, > > > Michael Guterl > > > -- > > > Posted viahttp://www.ruby-forum.com/.
I''m using what you suggested. Its working fine for development, but I''m not receiving email from production. Could you help me? thanks> > I certainly would not use a long running daemon for this purpose. You > should look into using cron and script/runner to execute the task daily. > > 0 8 * * * /path/to/rails/app/script/runner -e production > "Notifier.deliver_report_daily" > > This will deliver your daily report each day at 8 am. > > Best, > Michael Guterl > -- > Posted viahttp://www.ruby-forum.com/.
Now its working, thanks a lot> I certainly would not use a long running daemon for this purpose. You > should look into using cron and script/runner to execute the task daily. > > 0 8 * * * /path/to/rails/app/script/runner -e production > "Notifier.deliver_report_daily" > > This will deliver your daily report each day at 8 am. > > Best, > Michael Guterl > -- > Posted viahttp://www.ruby-forum.com/.