Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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 myShellScript.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

 
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.