1

I want to do a script, to automatize my tasks while I start my PC. The main idea is to use screen to do it. I wrote this, but It doesn't work. Only it builded the first session and then nothing more. This is the code

#!/bin/bash
screen -dmS angular sh -c 'cd Documents/segdet; ng serve --env=local'
screen -dmS jboss1 sh -x -c 'cd Documents/keycloak-2.3.0.Final/bin; ./standalone.sh -Djboss.socket.binding.port-offset=100 -b 0.0.0.0 &' 
screen -dmS jboss2 sh -x -c 'cd Documents/wildfly-10.1.0.Final/bin; ./standalone.sh -b 0.0.0.0 &' 

1 Answer 1

1

You need to use screen's -d option to get the screen session to disconnect after starting so it will move to the next one in the script.

Also using -S is useful to name the session so you can connect to the correct one later.

Something like this:

#!/bin/bash
screen -dmS angular sh -c 'cd Documents/file1; ng serve --env=local' 
screen -dmS jboss1 sh -x -c 'cd Documents/file2/bin; ./standalone.sh -Djboss.socket.binding.port-offset=100 -b 0.0.0.0 &' 
screen -dmS jboss2 sh -x -c 'wil' 'cd Documents/file3/bin; ./standalone.sh -b 0.0.0.0 &'

This will start 3 screen sessions named angular, jboss1 and jboss2

Sign up to request clarification or add additional context in comments.

3 Comments

I tried but It show me this "There is a screen on: 2399.angular (08/09/17 16:01:43) (Detached)".
Which means it's started the screen instance called angular in the background
Are you sure the commands for the second 2 sessions actually work? Also if they return then the screen sessions will exit immediately and not show up in the list (screen -ls).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.