starting a screen session on startup

hi, i have a raspberry pi connected to a small screen without a keyboard i want to be able to let it auto login and start a screen session that i can access and control via SSH. So i chose the custom auto-start option on AutoStart options and added the following command to custom.sh :

screen -S main

i also tried modifying rc.local with the same command. In both cases using

 screen -list

via ssh does not show any screen after start up, and the lcd monitor still shows ‘please login to continue’, am i missing something?

-m

causes screen to ignore the $STY environment variable. With “screen -m” creation of a new session is enforced, regardless whether screen is called from within another screen session or not. This flag has a special meaning in connection with the ‘-d’ option:

-d
-m Start screen in “detached” mode. This creates a new session but doesn’t attach to it. This is useful for system startup scripts.

https://linux.die.net/man/1/screen

Had to do some googlin’

So maybe screen -m-d -S main
might be the command you need

Then when you login with SSH, it should be waiting…but not attached

Tutorial for those that don’t know what screen is
https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/