Welcome Guest | Login

help with cronjob

i want to know if there is any step by step tutorial using ruby script to perform a task using cronjob. i want a simple step by step way to say send email every 1 hr. So it would be helpful if anyone could tell me :)
thanks in advance

2008-06-02 08:43 PM

Can you confirm the requirement. Do you want help to set up a cronjob for a rubyscript to send mails in every 1 hour...?

If so please log-in to your Cpanel>>cronjobs section and set the fields <path to ruby script>  <schedule time> correctly in such a way that it executes this ruby script every 1 hour.

If you still find trouble do post us a support request with the path to this ruby script file. We will set this up for you.

2008-06-03 01:19 AM

Regards,
Rahul
This is in home/my account/railsapp/app/controllers/xxx_controller.rb
===================================================

 def send_mails
    bas=Basicuser.find_by_sql "select email from basicusers where lower(username)='" + email + "' order by id"
    tempass=gen_random(6)

    if bas.length>0
      bas.length.times do |jj|
        Notifier::deliver_confirm(bas[jj].email)
      end
    end
 end

===================================================

This is in home/my account/railsapp/app/models/notifier.rb
====================================================

class Notifier < ActionMailer::Base

   def confirm(email)
     @recipients = email
     @from = "administrator@letters.com"
     @subject = "News Letter"
   # Email body substitutions go here
     @body="This is news letter."
   end

end

==================================================
i know that u need to use * 1 * * * for sending out every 1 hr
====================================================
but dont know how to string all these together..can one run this one and send out mail letters?

2008-06-03 11:53 AM

You need to put the Notifier::deliver_confirm(bas[jj].email) in a model, then use a script runner in your cron

* 1 * * * cd (your_rails_root) && /usr/local/bin/ruby script/runner Model.method

2008-06-03 01:59 PM

MN MLS - Buy/Sell Real Estate in Minnesota
@william ... thanks a lot for the help

2008-06-04 03:58 AM

I am looking for a very similar solution. What would be the proper way to set up ActsAsScheduled with a cron job?

2008-06-06 08:13 PM

I'm not familiar with that particular plugin (Google doesn't tell me much about it) but I'd imagine you could simply schedule a cron to call a method of a ActsAsScheduled model whenever you'd like...

the same deal (e.g. every hour):
* 1 * * * cd (your_rails_root) && /usr/local/bin/ruby script/runner Model.method

2008-06-07 01:34 AM

MN MLS - Buy/Sell Real Estate in Minnesota

Hello Guest! In order to post you must be an active client with us, please log in or sign up today!