0

Hi Guys i have a little problem.

Nkay let me explain this Ive got 3 Directorys with 3 different launch Scripts.

user/dir1/launch1.sh

user/dir2/launch2.sh

user/dir3/launch2.sh

user/startall.sh

How do i build a Script to start all 3 launch scripts with the startall script so that:

Every Script got his Own Tap?

My try so far:

#!/bin/bash
echo "Create Screen"
screen -AdmS Screenname -t Console bash
echo "Start htop"
screen -S Screenname -x screen -t Performance htop
echo "Start Script 1"
screen -S Screenname -x screen -t Tab1 ./dir1/launch1.sh
echo "Start Script 2"
screen -S Screenname -x screen -t Tab2 ./dir2/launch2.sh
echo "Start Script 3"
screen -S Screenname  -x screen -t Tab3 ./dir3/launch3.sh

If i use it like this it creates the session and the first tab. but then it freezes and does nothing.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • look for info on `screen` config files. I think you can set everything up there (but haven't needed to use this in years now, so I don't remember the exact options/limiations/etc). Good luck. – shellter Mar 06 '16 at 04:48

1 Answers1

0

This isn't clean (at all) but it works.

~/dir/script.sh

echo "killing scripts"
killall -9 python #kill all open python processes
echo "start 1"
cd /logs/1 #dir change so files from .py go to correct location
screen -md -S 1 python /logs/1/1.py #start 1.py in a screen named 1
echo "start 2"
cd /logs/2 #dir change so files from .py go to correct location
screen -md -S 2 python /logs/2/2.py #start 2.py in a screen named 2
echo "start 3"
cd /logs/3 #dir change so files from .py go to correct location
screen -md -S 3 python /logs/3/3.py #start 3 in a screen named 3
echo "sleeping"
#use screen -list to view running screens
#screen -x user/1 to see the screen named 1 etc 
#(personally I use 1 terminator window split x 8 to view 8 different python scripts)
#killall at start of script is because of thread hanging in my py script
#i crontab script.sh every hour (this is what the killall is for at the start of the
#script, so the previous runs processes don't eat processes)
#if you do not want to use killall -9 python, because of other running python scripts
#replace it with "pkill -f 1.py" for example, (pkill only takes one 'pattern'
#so each target needs its own line, so 3 lines of pkill to kill 1 2 3.py)