I want to run a python program (a infinite while loop as listener inside) when my instance (Amazon Linux AMI) boots up. I have created a simple shell script like this:
#!/bin/sh python bootstrap.py > bootstrap.log
Then I added the name of this script
run_service.sh in my
/etc/rc.local to run each time the instance boots up. But this simple approach seems not to be working, nothing happens. Both my shell script and python file are in
/home/ec2-user folder. Do I need to specify full path in both
rc.local and shell script for executing?
I found Amazon Linux AMI is CentOS/Fedora based, not Ubuntu. The cloud-init option seems not so clear, as I need to make this instance bundled into a customized AMI.
So, how can I do this by avoiding complex settings like puppet/chef, etc in a very simple way? For example, where to put my python file and the
run_service.sh script? Please give me a simple example.