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