So I have an EC2 instance setup, but in order for it to work the way I'd like to, I need to execute a script every time the EC2 instance is started, but for the life of me I cannot get the script to start when I start the instance. My EC2 instance is Ubuntu server 16, here's what I've tried so far
- adding
@reboot /path/to/myScript.sh
tocrontab
forroot
user - adding
myScript.sh
to the/etc/init.d
folder as well as the/etc/init
folder - adding
/path/to/myScript.sh
to myrc.local
- copying the script to
/var/lib/cloud/scripts/per-boot
Manually executing the script as root will work perfectly, but none of the above methods has worked for me, I'm not sure what I could possibly be missing here.
If it matters, what I'm trying to accomplish is to use yas3fs
to mount an s3
bucket as a fs to /mnt
which will contain media. Unfortunately yas3fs
doesn't work in the fstab
, so I need to execute the mounting command as a script.
yas3fs
but/usr/local/bin/yas3fs
(or whatever the path to the executable may be). The search path available to cronjobs or/etc/rc.local
, etc., contains fewer and/or different directories than you'll have with an interactive shell. Try that?