I use the 'whenever' gem for my rails cron file in EC2 and it works great. "Whenever -w" writes it and I never have to worry about it again. The problem is when my instance has a planned reboot. The rails app get passed to a new instance and the whole process is seamless with no downtime, but the new instance does not have my cron file.
How can I make sure that the cron file gets written when I move to a new instance? Is there a way to run it on app start or something like that? Thanks.
Whenever is a command. If you run:
bundle exec whenever --help
You will get a full list of flags. You'll want:
bundle exec whenever -w /path/to/schedule.rb
You can add a simple shell script to /etc/init.d
#!/bin/bash
cd /to/app && /full/path/to/bundle exec whenever -w /full/path/to/schedule.rb