thanks in advance
help with cronjob
- Mukund
- Posts: 2
- Starts: 1
- Wiki Edits: 0
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
thanks in advance
- Rahul
- Posts: 401
- Starts: 0
- Wiki Edits: 1
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.
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
- Mukund
- Posts: 2
- Starts: 1
- Wiki Edits: 0
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?
===================================================
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
- William
- Posts: 991
- Starts: 30
- Wiki Edits: 55
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
* 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- Mukund
- Posts: 2
- Starts: 1
- Wiki Edits: 0
@william ... thanks a lot for the help
2008-06-04 03:58 AM
- Adamwest
- Posts: 16
- Starts: 12
- Wiki Edits: 0
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
- William
- Posts: 991
- Starts: 30
- Wiki Edits: 55
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
the same deal (e.g. every hour):
* 1 * * * cd (your_rails_root) && /usr/local/bin/ruby script/runner Model.method