我可能没有正确设置。但我不确定为什么它不起作用。
这是我迄今为止的日程安排.rb:
require 'Employe.rb'
require 'Company.rb'
# Sets log output for whenever
set :output, 'log/whenever.log'
#Example
# every 3.hours do
# runner "MyModel.some_process"
# rake "my:rake:task"
# command "/usr/bin/my_great_command"
# end
# every 1.day, :at => '4:30 am' do
# runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
# end
# every :hour do # Many shortcuts available: :hour, :day, :month, :year, :reboot
# runner "SomeModel.ladeeda"
# end
# every :sunday, :at => '12pm' do # Use any day of the week or :weekend, :weekday
# runner "Task.do_something_great"
# end
# every '0 0 27-31 * *' do
# command "echo 'you can use raw cron syntax too'"
# end
# # run this task only on servers with the :app role in Capistrano
# # see Capistrano roles section below
# every :day, :at => '12:20am', :roles => [:app] do
# rake "app_server:task"
# end
# JOBTYPES
# job_type :command, ":task :output"
# job_type :rake, "cd :path && :environment_variable=:environment bundle exec rake :task --silent :output"
# job_type :runner, "cd :path && bin/rails runner -e :environment ':task' :output"
# job_type :script, "cd :path && :environment_variable=:environment bundle exec script/:task :output"
#Runs investment/loan transactions
every 1.day, :at => '12am' do
runner "Loan.repay_loans"
end
every :hour do
runner "Employe.employment_request"
runner "Company.generate_production"
end
#Runs end of day transaction calculations
# every 2.hours
# runner "Company.calculations"
# end
# every :sunday, :at => '12am'
# runner "Company.weekly_reset"
# end
如果我需要正常运行所需的一切,请告诉我。可能导致这种情况的原因。
谢谢。
答案 0 :(得分:0)
如果要在rails上下文中运行此脚本,请将其添加到文件顶部:
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
这假设您的脚本文件夹是根文件夹之一