blag: do not mark current date on calendar (otherwise ikiwiki-calendar would need...
[www-rohieb-name.git] / blag / post / gnu-screen-start-with-multiple-windows-and-commands.mdwn
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"]]
5
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
10 -r yoursessionname`.
11
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.
18
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:
22
23 screen
24 select 1
25 title "my window title"
26 exec mycommand arguments ...
27
28 [0]: http://www.gnu.org/software/screen/manual/
29
30 And, voilĂ , I could paste the single command line into my crontab:
31 `screen -dmS sessionname && screen -r sessionname -X source
32 sessioncommandfile`
33
34 [[!tag hacking howto cron GNU screen]]
This page took 0.044086 seconds and 5 git commands to generate.