Reputation: 4470
Is there a way to run in parallel? I can manually start screens, but I need to start up 30. I attempted to do it by hand (stupid yeah) but I got confused halfway through and decided I better ask stackoverflow.
#!/bin/bash --login
2
3
4
5
6 avida=~/avida/cbuild/bin/avida
7 skeleton_dir=~/cse845/no_pred
8 # wd=/mnt/scratch/cse845_avida/predator_sim
9 wd=~/cse845/no_predator_editor_sim_wd
10
11 for i in {1..30}
12 do
13 screen
14
15
16 sim_num=${i}
17 sim_dir=${wd}/sim_$sim_num
18 mkdir $sim_dir
19 cd $sim_dir
20 cp ${skeleton_dir}/*.cfg ${skeleton_dir}/*.org ./
21 $avida &> avida_log.txt
22# Here I would like to do the equivalent of exiting screen manually, ^A, d
23 done
Upvotes: 2
Views: 155
Reputation: 21
Here is how to start 3 at the same time in a shell script (the -d -m starts them in the background)
screen -s "name1" -c ~/screen/name1.screenrc -d -m
screen -s "name2" -c ~/screen/name2.screenrc -d -m
screen -s "name3" -c ~/screen/name3.screenrc -d -m
Then you could have a variable number of tabs/windows within each screen, specified in your screenrc files. (with -t).
See example screenrc file designed to work well with emacs: https://github.com/startup-class/dotfiles/blob/master/.screenrc
This is the only Section about specifying which tabs/windows per socket.
# 2.3) Autoload two screen tabs for emacs/bash.
screen -t emacs 0
screen -t bash 1
So when you do screen -ls you would get
There are screens on:
4149.name1 (07/10/13 22:18:44) (Detached)
4018.name2 (07/10/13 22:18:23) (Detached)
3882.name3 (07/10/13 22:17:08) (Detached)
3 Sockets in /var/run/screen/S-yourid.
And then if you wanted to connect to name1, you'd do screen -r 4149 or screen -r name1
Upvotes: 2
Reputation: 249592
I see two things right away:
-d
and -m
options.Upvotes: 0