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 until here ;-)) was more succesful: I created a session command file which contained screen commands like this:

select 1
title "my window title"
exec mycommand arguments ...

And, voilĂ , I could paste the single command line into my crontab: screen -dmS sessionname && screen -r sessionname -X source sessioncommandfile