3

Does anyone know the easiest way to run a rake task for a Rails app on an Elastic Beanstalk environment?

I have some data that I want to reset every once in a while (timeline TBD). I've seen other posts talking about creating a cron task, but I just want to be able to execute the task on a one-off basis for now.

Dennis
  • 938
  • 7
  • 17
  • Does this answer your question? [Can you run a rails console or rake command in the elastic beanstalk environment?](https://stackoverflow.com/questions/19620897/can-you-run-a-rails-console-or-rake-command-in-the-elastic-beanstalk-environment) – Yuki Inoue Mar 08 '20 at 08:00

2 Answers2

9

You'd need to login to the box in order to run a rake task.
simply run eb ssh <env-name>
your app is at /var/app/current

Tal
  • 7,136
  • 5
  • 32
  • 58
  • oh - just saw you found an answer. I think "eb ssh" would serve you better than plain ssh. – Tal Nov 12 '15 at 08:32
  • Yea, thanks for the tip on the "eb ssh." One thing I had to do was create a "known_hosts" folder in my .ssh directory and move a copy of my .pem key there to get it to work – Dennis Dec 03 '15 at 19:13
1

Figured out a way.

  • SSH into your EC2 instance using the following instructions: SSH Instructions (I used option 3)
  • Navigate to the /var/app/current directory once you're logged in
  • Run your rake task (rake db:migrate or whatever task you're trying to run)
Dennis
  • 938
  • 7
  • 17