1

I have my amazon instance, i need to add a shell script to its rc.local file so that the shell script executes when i boot my instance. how to set permission to my shell script in rc.local file?

if i execute as shown below , my script does not executes on startup

chmod u+x /home/mylin/exmpl.sh

./exmpl.sh &

pri_newbie
  • 13
  • 1
  • 1
  • 3

2 Answers2

1

You can use crontab to execute a command on boot:

http://www.cyberciti.biz/faq/linux-execute-cron-job-after-system-reboot/

you have to "chmod +x" your script and then use the full path.

chmod +x /home/mylin/exmpl.sh

And then in your crontab:

@reboot /home/mylin/exmpl.sh

Or in your rc.local file:

/home/mylin/exmpl.sh
Pascal Schmiel
  • 1,738
  • 12
  • 17
  • Hey! Thanks for the reply it works. my .sh file executed only after placing in crontab. i wonder why it didnt work using rc.local. Now all i need is to place my python script inside my shell script and execute it when my instance boots up. I tried using some small python scripts, it worked but when i tried it with my actual code it didnt. My actual python script is to download and upload some data from S3 buckets. can you please help me on this.. Im stuck with my s3 script it didnt work when i placed it inside my shell script which is in crontab! – pri_newbie May 06 '13 at 11:22
  • I think you should open a new question for this issue. – Pascal Schmiel May 06 '13 at 15:58
0

Make sure you're using the full path to your script in /etc/rc.local.

If your script is at /home/mylin/exampl.sh, the line in rc.local should be:

/home/mylin/exampl.sh &
Jason Floyd
  • 1,792
  • 1
  • 13
  • 18