If you need to run some cron jobs on server, check out the ruby gem whenever. It lets you write cron jobs in ruby way. You can do lots of useful thing using whenever, create database dumps/backups, run scripts/commands on reboot etc.
Using whenever to start unicorn on reboot
1. Add whenever to your Gemfile and run bundle command.
gem 'whenever', :require => false bundle
2.Writing a simple cron job
Move to the project directory and run
Now, open the file config -> schedule.rb and remove the default contents. Add these lines instead. (you need to replace
unicorn_app with whatever you’ve defined in your nginx config)
If you use capistrano for deployment, you should add this to
Next time, you push the code to the server, it will create the required cron jobs on the server. Make sure, it’s working as expected and let me know (via comments) if you’ve any issue.