0

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.

Chakron
  • 199
  • 12

1 Answers1

0

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
joncon
  • 105
  • 1
  • 7
  • I think you've answered my question, but I'm still stuck. I understand how to write to the cron file with Whenever. I want to execute the Whenever -w command when the rails server starts. Is that a command that is entered in production.rb? – Chakron Apr 09 '15 at 23:53
  • You need to create a simple shell script then either put it in init.d http://stackoverflow.com/questions/12973777/how-to-run-a-shell-script-at-startup or Do it the EC2 way http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html – joncon Apr 10 '15 at 03:21