Using cron
cd in to your repo and in the terminal, execute: crontab -e
EDITOR=nano crontab -e# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 6) (Sunday=0)
# | | | | |
* * * * * command to be executed
* to specify every unit of the part, so in the above you will schedule the task
every minute of every hour on every day of every month every day of the week.... Monday, Wednesday ...bundle exec rails db:migratecd into your application root and then call rake
0 0 * * * cd /my/app/root && /path/to/bundle exec rake some_taskwhich bundle from within your app's root to find the path to bundlerails runner ruby_code
0 * * * * cd /my/app/root && /path/to/bundle exec rails runner -e production "Model.long_running_method"-e production sets the environment to productionrails runner loads the app in memory first then evaluates the code in the environment
specified. When the task completes, the runner exits!gem "whenever", require: false to gemfile and then run bundle installbundle exec wheneverize
config/schedule.rbcd in app rootbundle exec whenever: schedule.rb is converted to cron syntaxbundle exec whenever -i: update crontabbundle exec whenever -w: overwrite the whole crontabbundle exec whenever -h: see helpSidekiq or if deployed on Heroku, Heroku Schduler