如何启动一个新的进程在新窗口在现有的GNU屏幕会话,会话外 [英] How to start a new process in a new window in an existing GNU screen session, from outside the session

查看:151
本文介绍了如何启动一个新的进程在新窗口在现有的GNU屏幕会话,会话外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里问过类似的问题,得到了pretty接近我正在寻找

I asked a similar question here and got pretty close to what I'm looking for

<一个href=\"http://stackoverflow.com/questions/1220797/how-to-start-a-process-from-another-application-and-then-open-a-terminal-to-that\">http://stackoverflow.com/questions/1220797/how-to-start-a-process-from-another-application-and-then-open-a-terminal-to-that

...但是,这并不完全得到我后,这是在现有的屏幕会话(不是一个新的屏幕会话),启动过程中的一个新窗口(而不是现有的窗口)。

...but, this doesn't quite get to what I'm after, which is starting a process in a new window (not an existing window) in an existing screen session (not a new screen session).

如果你是在一个屏幕会话的命令提示符下,你可以这样做:

If you are at a command prompt in a screen session, you can do this:

screen [screen options] command param1 param2

但是,你怎么做,如果你是会话之外?例如,如果你想作为一个cronjob运行此?

But, how do you do it if you are outside the session? For example, if you want to run this as a cronjob?

推荐答案

当你是不是在屏幕会话,你可以通过-X标志筛选执行命令屏幕。

When you aren't in a screen session, you can pass the -X flag to screen to execute a screen command.

例如,在屏幕屏幕命令打开一个新窗口,可被执行的命令。

For example, the screen command in screen opens a new window, optionally with a command to execute.

假设你已经有屏幕打开的话:

Assuming you already have screen open somewhere:

screen -dr -X screen sleep 20

请注意,新窗口(在这种情况下,睡眠)关闭,一旦命令完成。如果你想保持它打开,你可能会做这样的事情,这将在新的窗口中键入'日期\\ n':

Note that the new window will close once the command (sleep in this case) finishes. If you want to keep it open you could potentially do something like this, which will type 'date\n' in the new window:

screen -dr -X screen
screen -dr -X stuff "date
"

当然,手册页有更多的细节。

The man pages of course have much more detail.

这篇关于如何启动一个新的进程在新窗口在现有的GNU屏幕会话,会话外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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