Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I start my screen connection with a spawn command within an expect script: spawn screen /dev/...

But I don't know how I can kill the screen when the script is finished

share|improve this question
up vote 1 down vote accepted

When you run screen, use the -S option to give it a unique session name. Then, you can send it commands with the -X option. The quit command will kill the screen, like so:

$ screen -S myscreen -d -m
$ screen -ls
There is a screen on:
        2651.myscreen (09/06/2012 04:56:06 PM)        (Detached)
1 Socket in /var/run/screen/S-username.
$ screen -S myscreen -X quit
$ screen -ls
No Sockets found in /var/run/screen/S-username.
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.