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

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

问题描述

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

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

如何从另一个应用程序启动进程,然后打开终端到该进程gnu屏幕

...但是,这不会得到我的后,这是在一个新窗口中启动一个进程

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

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

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

screen [screen options] command param1 param2


b $ b

但是,如果你在会议之外,你该怎么办呢?

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

推荐答案

如果你不在屏幕会话中,你可以

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

注意,新窗口将在命令睡眠在这种情况下)完成。如果你想保持它打开你可以做这样的事情,这将在新窗口中键入date \\\

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天全站免登陆