I have an application that contains a bunch of tasks, and every day I want to run a cron job that creates a DayTask for each Task in the database. A Task has_many DayTasks and these daytasks are what users will be checking off every day. I'm using the whenever gem but it doesn't seem to be running at all. Any ideas?
config/schedule.rb
every 1.day, :at => "12:01am" do
runner "Task.generate_tasks_for_day"
end
Task.rb
def generate_tasks_for_day
Task.all.each do |task|
task.day_tasks.create(:target_date => Date.today)
end
end
result of running the 'whenever command'
1 0 * * * /bin/bash -l -c 'cd /home/grant/rails_projects/GoalTwist && script/rails runner -e production '''Task.generate_tasks_for_day''''
Note: I've been changing the times in config/schedule.rb every time I want to test run it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…