Essentail Rails Design Pattern

Write Good Rails Code

Ch6-when-ever

  • crontab should with projects, not with machines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 "DB.Backup"
end

every :hour do # Many shortcuts available: :hour, :day, :month, :year, :reboot
  runner "SomeModel.ladeeda"
end

every :sunday do # Use any day of the week or :weekend, :weekday 
  runner "Task.do_something_great"
end

Comments