Rails, using whenever gem in development

Step 1: Install the whenever gem by adding it to your Gemfile and running the bundle install command.

# Gemfile
gem 'whenever', require: false
$ bundle install

Step 2: Set up the schedule.rb file in the config directory to define your cron jobs using the whenever syntax.

# config/schedule.rb
every 1.day, at: '4:30 am' do
  runner 'MyModel.some_process'
  rake 'my:rake:task'
  command '/usr/bin/my_great_command'
end

Step 3: Generate and update the crontab file using the whenever command.

$ whenever --update-crontab

This will update the crontab file with the jobs defined in your schedule.rb file.

Step 4: Check the crontab entries using the crontab -l command.

$ crontab -l

Verify that the generated cron jobs match the ones you specified in schedule.rb.

Step 5: Run your Rails application and ensure that the scheduled tasks are executed at the specified times.

$ rails s

This step ensures that the whenever gem is integrated correctly with your Rails application and that the scheduled tasks are running as expected.