0

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 to crontab for root user
  • adding myScript.sh to the /etc/init.d folder as well as the /etc/init folder
  • adding /path/to/myScript.sh to my rc.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.

1
  • 1
    All of the commands in your script may need fully qualified paths... e.g., not 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? Nov 9, 2016 at 3:40

1 Answer 1

0

First, Make sure the file is executable. Set execute permission on your script:

chmod +x /path/myScript.sh

Enable logs : it will help you out with exact problem.

@reboot /path/to/myScript.sh > /path/cronlog.log 2>&1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .