Aws Ec2 在启动时运行脚本程序 [英] Aws Ec2 run script program at startup

查看:40
本文介绍了Aws Ec2 在启动时运行脚本程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有设置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.

推荐答案

可以在 User Data 属性中传递脚本.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆