<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Hello,<div><br></div><div>So I am using vncserver on a CentOS system from base repo. I have the systemd service enabled to start vncserver automatically on each boot.</div><div><br></div><div>I found out that vncserver is complaining about /tmp/.X11-unix/X1 socket file present almost each time shutdown is unclean due to freeze or power loss.</div><div><br></div><div>The service I am using that comes from base repo package looks like following. File is meant to be copied over to /etc/systemd/system with <USER> substituted accordingly.</div><div><br></div><div><div>[Unit]</div><div>Description=Remote desktop service (VNC)</div><div>After=syslog.target network.target</div><div><br></div><div>[Service]</div><div>Type=forking</div><div># Clean any existing files in /tmp/.X11-unix environment</div><div>ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'</div><div>ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"</div><div>PIDFile=/home/<USER>/.vnc/%H%<wbr>i.pid</div><div>ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'</div><div><br></div><div>[Install]</div><div>WantedBy=multi-user.target</div></div><div><br></div><div><br></div><div>It seems this is doing the right thing, it is calling "vncserver -kill" on configured display each time before vncserver, but somehow that doesn't work and in the log I see:</div><div><br></div><div><div>Jun 06 13:58:43 host runuser[1188]: pam_unix(runuser-l:session): session opened for user <myusername> by (uid=0)</div><div>Jun 06 13:58:43 host runuser[1188]: Warning: host:1 is taken because of /tmp/.X11-unix/X1</div><div>Jun 06 13:58:43 host runuser[1188]: Remove this file if there is no X server host:1</div><div>Jun 06 13:58:43 host runuser[1188]: A VNC server is already running as :1</div><div>Jun 06 13:58:43 host runuser[1188]: Warning: host:1 is taken because of /tmp/.X11-unix/X1</div><div>Jun 06 13:58:43 host runuser[1188]: Remove this file if there is no X server host:1</div><div>Jun 06 13:58:46 host runuser[1188]: New 'host:2 (srakit)' desktop is host:2</div><div>Jun 06 13:58:46 host runuser[1188]: Starting applications specified in /home/<myusername>/.vnc/<wbr>xstartup</div><div>Jun 06 13:58:46 host runuser[1188]: Log file is /home/<myusername>/.vnc/host:<wbr>2.log</div><div>Jun 06 13:58:46 host runuser[1188]: pam_unix(runuser-l:session): session closed for user <myusername></div></div><div><br><br>Any idea what is happening here, maybe a race condition?<br><br>If I restart the systemd service manually later it works, no problem. I don't know it /tmp/.X11-unix/X1 file exists immediately after an unsuccessful start, I always forget to check.</div></div>
</div><br></div>