Sometimes it would be nice to have screen start a detached session at start-up. This isn’t complicated. There are two steps. The first is to create a script to be run in the detached session and make it executable. We’ll call it start.sh
.
pico start.sh chmod +x start.sh
The second is to edit /etc/rc.local
to have the script run inside screen at start-up. Add the following line before the exit 0
line.
su - pi -c "screen -dm -S pistartup ~/start.sh"
That’s all there is to it. I found notes on this at https://coderwall.com/p/quflrg/run-a-script-on-startup-in-a-detached-screen-on-a-raspberry-pi.