How to run a shell script on my amazon instance when it bootsup?
12,681
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
Related videos on Youtube
Author by
pri_newbie
Updated on September 18, 2022Comments
-
pri_newbie over 1 year
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 about 11 yearsHey! 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!
-
Pascal Schmiel about 11 yearsI think you should open a new question for this issue.