mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
Merge pull request #1446 from GOLinux/master
Translated:20140804 Linux FAQs with Answers--How to check if I am in a running screen session.md
This commit is contained in:
commit
e1f40de287
@ -1,25 +0,0 @@
|
||||
Translating by GOLinux ...
|
||||
Linux FAQs with Answers--How to check if I am in a running screen session
|
||||
================================================================================
|
||||
> **Question**: I often use screen command to run multiple pseudo terminal sessions. Oftentimes I find it difficult to remember whether I am inside a screen session, or in a regular terminal. Is there any convenient way to check whether or not I am inside a running screen session?
|
||||
|
||||
One quick and easy way to tell whether you are inside a screen's pseudo terminal or in a regular terminal is to check STY environment variable. When screen is invoked, it sets STY variable to a session name. So if STY environment variable is set to any non-empty string, that means you are inside a screen session.
|
||||
|
||||
$ echo $STY
|
||||
|
||||
> 2858.pts-3.my_host
|
||||
|
||||
However, note that the above method works **only if** you are still on a local computer where you run screen command. If you SSH to any other remote computer from the local computer's screen session, STY variable will not be set on the remote computer while you are technically still in a screen session.
|
||||
|
||||
In fact, a more reliable way to check if you are in a screen session is to press "Ctrl-a"+"Ctrl-t". If you are in screen, the terminal will show you time information at the bottom of the terminal.
|
||||
|
||||

|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/check-running-screen-session.html
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -0,0 +1,24 @@
|
||||
Linux常见问题与答案——如何检查我是否处于一个运行着的screen会话中
|
||||
================================================================================
|
||||
>**问题**:我经常使用screen命令来运行多个伪终端会话。好多次,我发现都记不得自己是否在一个screen会话中,还是在一个常规终端中。是否有一种简便的方法来检查我是否在一个运行着的screen会话中?
|
||||
|
||||
一个快捷而又简单的方法来检查你是否处于一个screen伪终端中,还是在一个常规终端中,就是检查STY环境变量。当调用了screen,就会把STY变量值设置为会话名。因此,如果STY环境变量被设置为任何非空字符串,就意味着你正处于一个screen会话中。
|
||||
|
||||
$ echo $STY
|
||||
|
||||
> 2858.pts-3.my_host
|
||||
|
||||
然而,请注意,上面的方法**只有当**你是在本地计算机上运行screen命令的时候。如果你从本地计算机的screen会话中SSH到任何远程计算机上,远程计算机上的STY变量不会被设置,尽管在技术上看,你仍然处于一个screen会话中。
|
||||
|
||||
事实上,一个更为可靠的检查你是否处于一个screen会话中的方法,是按“Ctrl-a”+“Ctrl-t”。如果你处于screen会话中,终端会在底部显示时间信息。
|
||||
|
||||

|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/check-running-screen-session.html
|
||||
|
||||
译者:[GOLinux](https://github.com/GOLinux)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user