Skip to main content

VNC Client Configuration (TigerVNC)

Linux VNC Connection Service:

Please save the following script to reconnect vnc

Step 1/3: shell script to retrying - copy the following script to /usr/local/bin/vnc-reconnect.sh

please give execute permission as given below

chmod +x /usr/local/bin/vnc-reconnect.sh

Step 2/3: service daemon configuration

please create the file - /etc/systemd/system/vnc-reconnect.service and copy the following contents

[Unit]
Description=VNC Reconnect Service
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/local/bin/vnc-reconnect.sh
Restart=always
RestartSec=10
User=<username>
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/<username>/.Xauthority

[Install]
WantedBy=multi-user.target

Step 3/3: after doing both 1/2 and 2/2 steps; please run the following:

sudo systemctl daemon-reload
sudo systemctl enable vnc-reconnect.service
sudo systemctl start vnc-reconnect.service

sudo systemctl status vnc-reconnect.service

For checking logs

journalctl -u vnc-reconnect.service -b