Issue
I would like to set up an EC2 instance running an ipython notebook server for personal data science projects. I can successfully get the server up and running, and access it from my browser, etc... I'm using Ubuntu 14.04 for my OS.
However, because I want to use a pretty big instance, it would get really expensive to leave it running all the time, so I want to be able to start and stop it when I don't need it. Currently, this means that I need to ssh into the instance and restart the server every time I start it up. I would like some way to run ipython notebook --profile=nbserver
when the instance starts, so that I can start the instance an immediately access my server from my browser.
I put
#!/bin/bash
ipython notebook --profile=nbserver
in the user-data, but this doesn't appear to work. I'm unable to find a clear answer on whether user-data scripts are run only on first launch, or whenever the instance starts.
Is there another place I could put that script so that it would run whenever I start the instance?
Solution
Here's what the AWS documentation says about cloudinit being at launch or start, highlights mine:
a set of cloud-init directives that executes when the instance launches ... Important: User data scripts and cloud-init directives only run during the first boot cycle when an instance is launched.
The easiest way to get something to start on every boot is to put lines in your rc.local
. Here's an example from a stackoverflow question; certainly there are better ways to do it (so that, for instance, the notebook restarts itself if it dies for some reason), but that's enough to get started.
Answered By - tedder42
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.