[英]How to run Screen command on EC2 instance from Python script
I have tried launching a EC2
instance from pycharm using a Python
script. 我尝试使用Python
脚本从pycharm启动EC2
实例。 As part of the launch process, I have downloaded a .sh script from s3 and have executed below commands. 作为启动过程的一部分,我从s3下载了.sh脚本并执行了以下命令。
commands = [
"aws s3 cp s3://sample/test.sh /home/ubuntu/test.sh",
"chmod +x /home/ubuntu/test.sh",
"sudo apt-get update",
"./test.sh"
]
However, when the last command './test.sh'
is executed, I want to get out of the flow and create few more instances. 但是,当执行最后一个命令'./test.sh'
,我想退出流程并创建更多实例。 But, as the script ./test.sh
is a long running script, its not exiting the loop. 但是,由于脚本./test.sh
是长时间运行的脚本,因此不会退出循环。 I would like to submit the job as a background Screen
job, but, was not able to open a screen using python code snippets. 我想将该作业提交为后台Screen
作业,但是无法使用python代码段打开屏幕。 I am using paramiko
module to connect to EC2
instance. 我正在使用paramiko
模块连接到EC2
实例。
我已经将上述声明从./test.sh
为screen -d -m ./test.sh
,这对我来说很有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.