Reputation: 323
I have followed ec2 run scripts every boot and tried the same approach for per-instance but my script still doesn't get executed.
I also followed Execute User Data After the Initial Launch of Your EC2 Instance and yet the script doesn't get executed. Content of the script:
nohup /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/python3 -u medi_app.py &> nohup_medi &
Why is it proving so hard to run a script every time an instance restarts? Can someone please help out here?
Upvotes: 0
Views: 4667
Reputation: 269091
If you are using an Amazon EC2 Linux instance to run a batch job on startup, simply install the script in this directory:
/var/lib/cloud/scripts/per-boot/
This will work on any system that has cloud-init installed, which also runs User Data scripts.
For more details, see: Auto-Stop EC2 instances when they finish a task - DEV Community
Upvotes: 4