启动屏幕(unix 命令)+在 1 个命令中运行一个命令?
想知道如何启动一个命令,例如:
while :; do ./myCommand; done;
但我不想执行通常的“
screen -S nameOfMyScreen
然后命令
while :; do ./myCommand; done;
然后分离屏幕”,
^a ^d (Control "a" the control "d"
我希望它启动并分离。谢谢!
Was wondering how I can start up a command such as:
while :; do ./myCommand; done;
But instead of doing the usual
screen -S nameOfMyScreen
Then the command
while :; do ./myCommand; done;
Then detach the screen
^a ^d (Control "a" the control "d"
I would like it to start and detach. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
说明:
-d -m
以分离模式启动屏幕(创建会话但不附加到它)sh -c commandline
启动一个执行给定命令行的 shell (必要的,因为您使用的是while
内置函数)。Explanation:
-d -m
starts screen in detached mode (create session but don't attach to it)sh -c commandline
starts a shell which executes the given command line (necessary, since you are using thewhile
builtin).从
screen -h
来看,这些看起来很有用:我自己没有这样做过,但这就是我要开始的地方。
更新:
帮助的顶部还指出
,
-X
开关可能会执行 screen 命令,如下所示与shell命令相反。您可以将命令放在-dmS
之后,而无需任何-X
开关。From
screen -h
, these look useful:I haven't done this myself, but that's where I'd start.
Update:
The top of the help also says
so the
-X
switch may be to execute a screen command as opposed to a shell command. You might just be able to put your command after the-dmS <name>
without any-X
switch.