On CentOS 7.I have edited /etc/rc.d/rc.local, and made it executable, and I am starting a screen session from it.Problem is, when I log to server as root, I am not seeing screen sessions started from rc.local, under screen -ls run as root user.If I do ps axuf | grep -i screen, I see screen sessions are active, and I can see processes inside screen are running.How do I attach myself to this screen sessions?My rc.local section for screen looks something like this./usr/bin/screen -wipe/usr/bin/screen -dmS scr1 /script/rsync1.sh/usr/bin/screen -dmS scr2 /script/rsync2.sh/usr/bin/screen -dmS scr3 /script/rsync3.sh/usr/bin/screen -dmS scr4 /script/rsync4.sh/usr/bin/screen -dmS scr5 /script/rsync5.shI can see screen sessions are started with ps auxf after server boot.root@server [~]# ps auxf | grep -i screenroot       90642  0.0  0.0 112648   988 pts/0    S+   21:54   0:00          \_ grep --color=auto -i screenroot        3384  0.0  0.0 127784  2212 ?        Ss   21:33   0:00 /usr/bin/SCREEN -dmS scr1 /script/rsync1.shroot        3390  0.0  0.0 127784  2252 ?        Ss   21:33   0:00 /usr/bin/SCREEN -dmS scr2 /script/rsync2.sh    root        3393  0.0  0.0 127784  2252 ?        Ss   21:33   0:00 /usr/bin/SCREEN -dmS scr3 /script/rsync3.shroot        3398  0.0  0.0 127784  2252 ?        Ss   21:33   0:00 /usr/bin/SCREEN -dmS scr4 /script/rsync4.shroot        3403  0.0  0.0 127784  2248 ?        Ss   21:33   0:01 /usr/bin/SCREEN -dmS scr5 /script/rsync5.shIf i try to do screen -r scr1, I will get that there is no such screen running.Sessions are running as root, so I am not sure why am I not able to see them.I have tried adding /usr/bin/sudo to beginning of commands, but then it fails to start completely.Jul 10 22:07:37 server systemd[1]: Starting /etc/rc.d/rc.local Compatibility...Jul 10 22:07:39 server rc.local[3645]: sudo: sorry, you must have a tty to run sudoJul 10 22:07:39 server rc.local[3645]: sudo: sorry, you must have a tty to run sudoJul 10 22:07:39 server rc.local[3645]: sudo: sorry, you must have a tty to run sudoJul 10 22:07:39 server rc.local[3645]: sudo: sorry, you must have a tty to run sudoJul 10 22:07:39 server rc.local[3645]: sudo: sorry, you must have a tty to run sudoJul 10 22:07:39 server systemd[1]: rc-local.service: control process exited, code=exited status=1Jul 10 22:07:39 server systemd[1]: Failed to start /etc/rc.d/rc.local Compatibility.Jul 10 22:07:39 server systemd[1]: Unit rc-local.service entered failed state.Jul 10 22:07:39 server systemd[1]: rc-local.service failed.Also, the screen -wipe on the start, doesn't seem to affect sessions that were started manually outside rc.local.In case server crashes, screens that were started manually will still be shown as dead in screen -ls under root.I have added this to rc.local, and not to crontab with @reboot, because that would not work in case system crashes or gets powered off/shutdown without reboot, it would only get triggered on reboots, as far as I understand @reboot in cron.Solved by Stephen Harris comment about $SCREENDIR.In your startup script do a screen -ls > /tmp/xyzzy.$$ (or similar  filename) - that'll tell you what directory it has stored the sockets  in. You may need to set $SCREENDIR to point to this directory in order  to see the sessions when trying to re-attach.  Stephen Harris 10  hours agorc.local used /var/run/screen/S-root as SCREENDIRroot used /root/screens as SCREENDIR, which is why it didn't see sessions from rc.localNote:It is not needed to add screen -ls > /tmp/xyzzy.$$ to rc.local to find which folder is used as SCREENDIR. It can be seen by doing systemctl status rc-local, it will show something like this in output rc.local[3258]: No Sockets found in /var/run/screen/S-root.After doing export SCREENDIR=/var/run/screen/S-root screen -ls shows screens started from rc.local
Screen session started from rc.local is not visible in screen -ls under root
gnu screen
Solved by Stephen Harris comment about $SCREENDIR.In your startup script do a screen -ls > /tmp/xyzzy.$$ (or similar  filename) - that'll tell you what directory it has stored the sockets  in. You may need to set $SCREENDIR to point to this directory in order  to see the sessions when trying to re-attach.  Stephen Harris 10  hours agorc.local used /var/run/screen/S-root as SCREENDIRroot used /root/screens as SCREENDIR, which is why it didn't see sessions from rc.localNote:It is not needed to add screen -ls > /tmp/xyzzy.$$ to rc.local to find which folder is used as SCREENDIR. It can be seen by doing systemctl status rc-local, it will show something like this in output rc.local[3258]: No Sockets found in /var/run/screen/S-root.After doing export SCREENDIR=/var/run/screen/S-root screen -ls shows screens started from rc.local