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


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'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.