Super User is a question and answer site for computer enthusiasts and power users. 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 need a certain program to run inside a gnu screen session, automatically when an ubuntu machine boots.

How can I set it up so that later on I can just screen -r and interact with the program?

share|improve this question
up vote 4 down vote accepted

Just use

screen -d -m command

Quoting the documentation:

Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.

But keep in mind that once the command finishes, the screen terminates as well.

share|improve this answer
i would use this, then call the shell, and pass a command to the shell and tell it not to terminate – Roy Rico Jun 10 '12 at 21:08
if the screen terminates when the command finishes, it doesn't solve my problem. how would i get to not terminate? – GJ. Jun 11 '12 at 8:28
@GJ. Do you need to "interact with the program" or inspect its output? You can not interact with a program after it finishes. – choroba Jun 11 '12 at 11:03
I need to interact with it while it's running, and inspect its output after it finishes – GJ. Jun 11 '12 at 21:52
@GJ. So create a script that calls the command and then waits for Enter (read). Call this script from screen -d -m. – choroba Jun 11 '12 at 21:55

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.