AWS Ec2在启动时运行脚本程序 [英] Aws Ec2 run script program at startup
问题描述
有没有一种方法可以设置EC2计算机以在启动时执行Kafka启动脚本?
我也使用java Aws SDK,因此我接受在EC2实例上运行命令的程序java的解决方案,以及在启动时运行kafka脚本的bash脚本模式的解决方案。
There is a method to setup an EC2 machine to execute Kafka starting script on startup? I use also java Aws SDK, so I accept both solution for a program java that run command on EC2 instance and solutions for a bash script mode that run kafka script at startup.
推荐答案
可以在用户数据属性中传递脚本。
A script can be passed in the User Data property.
如果正在使用Amazon Linux AMI,脚本的第一行以#!
开头,然后将在首次启动实例时执行脚本。
If you are using the Amazon Linux AMI, and the first line of the script begins with #!
, then the script will be executed the first time that the instance is started.
有关详细信息,请参见:在启动时在Linux实例上运行命令
For details, see: Running Commands on Your Linux Instance at Launch
这篇关于AWS Ec2在启动时运行脚本程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!