1 [[!meta title="GNU screen: start with multiple windows and commands"]]
2 [[!meta date="2010-07-30"]]
3 [[!meta author="rohieb"]]
4 [[!meta license="CC-BY-SA 3.0"]]
6 I wanted to restart my IRC bot on reboot, but I also wanted to have
7 control over it and see its log output, so I wanted to start it inside a
8 `screen` session. This is nearly trivial, `screen -dmS yoursessionname
9 yourcommand` is your friend, and you can later on reattach using `screen
12 But what if I want to start multiple commands, each in its own screen
13 window? My first solution used `screen -dmS` followed by something like
14 `screen -r sessionname -X screen; screen -r sessionname -X next; screen
15 -r sessionname -X title "my window title"; screen -r sessionname -X exec
16 "my command line"`, but it seems that the `next` command fails in this
17 context, and I ended up with all the mess in one single window.
19 My next approach (okay, it took me half an hour of reading [the
20 manual][0] until here ;-)) was more succesful: I created a session
21 command file which contained screen commands like this:
25 title "my window title"
26 exec mycommand arguments ...
28 [0]: http://www.gnu.org/software/screen/manual/
30 And, voilĂ , I could paste the single command line into my crontab:
31 `screen -dmS sessionname && screen -r sessionname -X source
34 [[!tag hacking howto cron GNU screen]]