I am trying to run x11vnc as service to start it on boot. Below is the code that I am using drawn from the two answers here.
[Unit]
Description=VNC Server for X11
Requires=display-manager.service
After=display-manager.service
[Service]
Type=forking
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/vnc.passwd -rfbport 5902 -shared
ExecStop=/usr/bin/x11vnc -R stop
Restart=on-failure
RestartSec=2
[Install]
WantedBy=multi-user.targetThen I run:
sudo systemctl daemon-reload sudo systemctl enable x11vnc.service sudo systemctl start x11vnc.serviceOn the last command, I get the following error message.
Job for x11vnc.service failed because a timeout was exceeded. See "systemctl status x11vnc.service" and "journalctl -xe" for details.There is no conclusive answer on systemctl status x11vnc.service or journalctl -xe but I can supply if needed.
Another thing I noticed is that the ports 5900, 5901 could be open or closed in different boots. I don't know which process is taking them.
The code below works but it can't start when integrated in the service above.
When restarting Ubuntu, it works initially and stops working after few minutes.
exec /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/vnc.passwd -rfbport 5902 -sharedUbuntu Version: Ubuntu 16.04.6 LTS Release: 16.04 Codename: xenial
Is there anything I am missing that prevents x11vnc from starting?
31 Answer
This is not a fix but a workaround. I used sudo crontab -e to store run the x11vnc at startup. I just needed to add this below at the end of crontab.
@reboot exec /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/geodev/.vnc/passwd -rfbport 5900 -sharedRunning it in sudo is important to start x11vnc before login of any user.