[英]How to execute a program with command line arguments on EC2 remotely (java program)?
I want to start a EC2 instance from java code and execute python code on that EC2 instance.我想从 java 代码启动一个 EC2 实例并在该 EC2 实例上执行 python 代码。
I have done some analysis where I can create AMI with python code and launch EC2 instance, but I am looking for a way to launch multiple instances of python program with command line arguments.我已经做了一些分析,我可以用 python 代码创建 AMI 并启动 EC2 实例,但我正在寻找一种方法来启动带有命令行参数的 python 程序的多个实例。
Basically I want to build a scalable system which will start EC2 instance and launch multiple python processes as per requirement and will remove EC2 instance as work is done.基本上我想构建一个可扩展的系统,它将启动 EC2 实例并根据需要启动多个 python 进程,并在工作完成时删除 EC2 实例。
UPDATE: Although accepted answer is correct there is another way to execute scripts remotely using ssh tunneling using JSCH java library , here is the Gist for sample code更新:虽然接受的答案是正确的,但还有另一种使用 JSCH java 库使用 ssh 隧道远程执行脚本的方法,这里是示例代码的要点
This can be used for communication with non AWS machine with SSH service on.这可用于与开启 SSH 服务的非 AWS 机器进行通信。
You can use AWS Systems Manager to invoke shell commands on your remote EC2 instance.您可以使用 AWS Systems Manager 在远程 EC2 实例上调用 shell 命令。
Managed Instance
inside SSM.将该角色附加到该实例并等待该实例进入 SSM 内的Managed Instance
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.