sinaxtis
sinaxtis

Reputation: 69

Screen GNU Script Bash

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 &' 

Upvotes: 1

Views: 143

Answers (1)

hardillb
hardillb

Reputation: 59826

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

Upvotes: 1

Related Questions