This question already has an answer here:
I need some persistent storage across spot terminations.
My approach to solve the problem is
Write a startup script that attaches and mounts the persistent volume
Snapshot this state and register a private AMI
Launch Spot instances based of the private AMI
searches in this forum  suggests this is the correct procedure
My startup script:
#!/bin/sh echo "executing startup script" # attach the EBS volume to this machine aws ec2 attach-volume --volume-id vol-7bef1d96 --instance-id $(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id ) --device /dev/xvdg sleep 10 # mount the attached EBS volume echo "mounting the attached volume" sudo mount /dev/xvdg1 /home/ubuntu/persistent/ #run script echo "starting the dummy program in background" python2 persistent/dummyProgram.py &
The script works perfectly if executed manually. However when it is executed by cron the only the echo statement are executed
the crontab task is
How do I solve this problem?
The corrected crontab entry reads :
USER=username PATH=content of $PATH @reboot /path/to/startupScript.sh