Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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
1  
@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

 
discard

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.