Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using a shell script, how can you tell if a screen is running using shell scripts?

For example, using pseudocode:

IF (screen.screenname.running == TRUE)

or something like that.

share|improve this question
what's your eventual goal? (I wonder if you are going to say that you want to do something which can be achived instead by screen -d -R or pgrep or ? – stew Feb 17 '12 at 15:56
One way to tell the GNU screen is running is to check the TERM variable: if the remote server recognizes the screen terminal, then this will work. However, this is not a reliable indicator: one could use vt100 just as well. (In my session, I see TERM=screen-bce.) However, I concur with @stew: What are you trying to do? – Mei Feb 17 '12 at 16:42
@David me? just help him with his question :) – stew Feb 17 '12 at 16:44
@stew: Nah: I'm asking the original poster the same question you did. That's all. – Mei Feb 17 '12 at 17:51
if `screen -ls <screenname> | grep -q "There is a screen on"`; then
    echo "<screenname> is running"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.