In terminal i write: ruby lib/scripts/script.rb
In on script.rb I have 2 scripts...
script.rb
require 'config/environment'
#first script
#notifier user that question deadline is over and show statistics
inquiry.each do |i|
question = i.question
#respondent = Respondent.find(:all, :conditions => ["id = (?)", i.respondent_id])
respondent = i.respondent
#Notifier.deliver_deadline_notification(inquiry, user, question, respondent)
Notifier.deliver_statistics_notification(inquiry, question, user, respondent)
#respondent = Respondent.find(:all, :conditions => ["id = (?)", i.respondent_id])
#respondents.each do |r|
#end
end
-----------------
#second script
respondents = Respondent.find(:all)
inquiries = Inquiry.find(:all, :conditions => ["is_answered = 0 AND respondent_id = (?)", respondents])
#respondents = Respondent.find(:first, :conditions => ["id = (?)", inquiries])
questions = Question.find(:all)
qdead = questions.deadline
dead_line_date = qdead - 1.days - 0.minutes - 0.seconds
get_time_now = Time.now.strftime('%m/%d/%Y')
I have those 2 scripts (1 script do something ,and second is another) in one rb file. My question is... How do I can write in console to launch 1st script and 2nd script simultaneously? I know i use some AGVG ? But How?
Thank you very much!
UPD: using cron i wrote:
0 0 * * * /usr/bin/rails-run-script myproject script oncoming
0 1 * * * /usr/bin/rails-run-script myproject script missed
d
oncoming and missed - arguments. How i can deprecate them in my script.rb. How script will know that Im using missed or oncoming ?