bash GNU Screen - 在 shell 或脚本的后台运行命令中创建屏幕
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/11491700/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GNU Screen - create screen in background run command from shell or script
提问by jahil
I am trying to create a screensession/window from the shell and launch a command in it. How would I do that?
我正在尝试screen从 shell创建一个会话/窗口并在其中启动一个命令。我该怎么做?
回答by Thor
If you want to launch and connect to screen:
如果要启动并连接到屏幕:
screen CMD
If you want to launch and not connect to screen:
如果您想启动而不连接到屏幕:
screen -dm CMD
Works with sessions too:
也适用于会话:
screen -Sdm NewDetachedSessionName
回答by Eslam Saber
first create new session :
首先创建新会话:
screen -dmS [session_name]
screen -dmS [session_name]
then attach command or script to run in session created :
然后附加命令或脚本以在创建的会话中运行:
screen -x [session_name] [script.sh]
screen -x [session_name] [script.sh]

