I'm trying to run multiple scripts in detached screen sessions at the same time.
This is the code I currently have.
#!/bin/bash
screen -mdS Name_Screen1 "python /path/to/file/file.py arg1 arg2 arg3"
screen -mdS Name_Screen2 "python /path/to/file/file.py arg3 arg4 arg5"
screen -mdS Name_Screen3 "python /path/to/file/file.py arg6 arg7 arg8"
When typing "screen -list" to see what screens are available, I don't see any of the screens I'm currently running. This scripts outputs some information to the screen, which depends on the arguments given. I've looked through some of the problems posted in here, but I can't find an answer for this.
Is there any way I can look at the outputs of these screens without having to do something like "> out.txt"?
Update
So I finally figured it out. I ended up creating just one screen session and multiple windows within the session.
#!/bin/sh
Lum_Types=("Window1" "Window2" "Window3" )
Windowname="Screen_session"
screen -mdS $Windowname
for Lum in ${Lum_Types[@]}
do
screen -S $Windowname -X screen -t $Lum
screen -S $Windowname -p $Lum -X stuff $"python /Path/to/file arg1 arg2"
screen -S $Windowname -p $Lum -X stuff $'\n'
done
One key part was to add the $
after the -X stuff
in order to pass the string to the screen session and windows.
So I finally figured it out. I ended up creating just one screen session and multiple windows within the session.
#!/bin/sh
Lum_Types=("Window1" "Window2" "Window3" )
Windowname="Screen_session"
screen -mdS $Windowname
for Lum in ${Lum_Types[@]}
do
screen -S $Windowname -X screen -t $Lum
screen -S $Windowname -p $Lum -X stuff $"python /Path/to/file arg1 arg2"
screen -S $Windowname -p $Lum -X stuff $'\n'
done
One key part was to add the $
after the -X stuff
in order to pass the string to the screen session and windows.
– Victor