如何从会话外部在现有 GNU 屏幕会话的新窗口中启动新进程

发布于 2024-07-30 10:55:20 字数 454 浏览 2 评论 0原文

我在这里问了一个类似的问题,并且非常接近我正在寻找的内容

如何从另一个应用程序启动一个进程,然后在 gnu screen 中打开该进程的终端

...但是,这并没有完全解决我所追求的,是在现有屏幕会话(不是新屏幕会话)的新窗口(不是现有窗口)中启动一个进程。

如果您处于屏幕会话中的命令提示符处,则可以执行以下操作:

screen [screen options] command param1 param2

但是,如果您不在会话中,该怎么办? 例如,如果您想将其作为 cronjob 运行?

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

How to start a process from another application and then open a terminal to that process in gnu screen

...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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安稳善良 2024-08-06 10:55:20

当您不在 screen 会话中时,您可以将 -X 标志传递给 screen 来执行 screen 命令。

例如,screen 中的 screen 命令会打开一个新窗口,其中可以选择包含要执行的命令。

假设您已经在某处打开了屏幕:

screen -dr -X screen sleep 20

请注意,一旦命令(在本例中为睡眠)完成,新窗口将关闭。 如果您想保持它打开,您可以执行类似的操作,这将在新窗口中键入“date\n”:

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

手册页当然有更多详细信息。

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文