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 have a shell script that makes a backup of my server files before starting it. However I wish it to instead of just running it open a new screen session and then start it from there. Once its running I want to periodically send commands to it.

Anyone know how to run screen like this?? I have found tons of stuff but very little of it assumes I'm running it from a shell script (instead of just typing it into the terminal window).

share|improve this question

If I'm understanding you right, you can do it this way.

To launch the shell script in a screen session:

screen -dmS MyScreenSession sh

Thereafter, if you want to send commands to the script without having to bring up the screen session, you can use this command:

screen -p 0 -S MyScreenSession -X eval 'stuff "Some command goes here"\015'
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.