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

I often have 5+ screens open for monitoring the server within one screen and it's somewhat annoying to have setup them all up again after a system restart. Usually there is 1 top process and a few tails for watching log files.

Is there a way to have screen automatically open a number of screens with certain commands executed in each scren?

share|improve this question
Could you add a note indicating that this related to GNU Screen - it's very confusing to read otherwise... – Le Comte du Merde-fou Aug 6 '09 at 17:04
@mh I added some more tags, thanks for pointing this out. – Andy May Aug 6 '09 at 17:27
up vote 7 down vote accepted

Yes, you can put this into your screenrc, eg.

screen -t Code 0
screen -t Chat 1 irssi
screen -t Shell 2
screen -t Remote 3 ssh user@host
screen -t screen4 4
share|improve this answer

You can put the commands in a text file, and then specify that text file as your screenrc, screen will still inherit the entries from the system screenrc file in /etc. The text file might look like:

zombie qr
screen -t sshToServer1 ssh Server1
screen -t logTail tail -f /var/log/foo

The Syntax is:

screen -t title <optional window number> command commandArguments

The zombie qr will make it so if you close that window, you can resurrect it by pressing r. To specify the above text file:

screen -c textfile

If you want to name the screen session, and have reattach the name if there is already a detached session with the same name instead of starting a new one, use -R:

screen -R myScreenSession -c textfile

This way, you can save several different text files for different screen sessions.

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.