Welcome to the Linux Foundation Forum!

LFS211: LAB 5.8 - VNC Server Autostart - Timeout with provided vncserver@.service

Hi,

I have been trying to create a vncserver@.service and ran into issues that I managed to fix. However, since I fixed it by modifying the service content proposed in the Solutions of the lab 5.8, I propose here the content that made it work:

Static hostname: UbuntuLTS
Chassis: vm
Virtualization: kvm
Operating System: Ubuntu 20.04.2 LTS
Kernel: Linux 5.8.0-44-generic
Architecture: x86-64

vncserver@.service proposed by lab solutions:

  1. /etc/systemd/system$ cat vncserver@.service
  2. [Unit]
  3. Description=Remote desktop service (VNC) on port :%I
  4. After=syslog.target network.target
  5.  
  6. [Service]
  7. Type=forking
  8. User=username
  9.  
  10. ExecStartPre=-/usr/bin/vncserver -kill :%i
  11. ExecStart=/usr/bin/vncserver :%i -localhost
  12. PIDFile=/home/username/.vnc/%H:%i.pid
  13. ExecStop=-/usr/bin/vncserver -kill :%i
  14.  
  15. [Install]
  16. WantedBy=multi-user.target

Performing the systemctl daemon-reload and starting it with systemctl start vncserver@41.service resulted in a timeout:

  1. Job for vncserver@41.service failed because a timeout was exceeded.
  2. See "systemctl status vncserver@41.service" and "journalctl -xe" for details.

Commenting out the both lines:

  1. # ExecStartPre=-/usr/bin/vncserver -kill :%i
  2. # PIDFile=/home/username/.vnc/%H:%i.pid

Made the service to start and run properly.

It seems that the first comment is needed as the ExecStartPre fails to kill the (in)-existing vncserver process, while the second comment I am not sure why it was timing out as I do have in my ~/.vnc folder a UbuntuLTS:41.pid, corresponding to the %H:%i.pid

How relevant is that PIDFile line in the service, and why doesnt it work?

Thanks!

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 1,272

    Hi @LioC ,

    Did you change "User=username" by your username in the configuration file?

    Regards,
    Luis.

  • Posts: 7

    Hi Luis (Lionel here),

    yes, I did, and we were yesterday troubleshooting the same service on the same VM. But then, the username filds were not properly set in the both "username" locations, and the error messages we had then related to it.

    Now, the username fields have been updated correctly, the service runs but not without commenting out the ExecStartPre and PIDFile lines.

    Regards,

    Lionel.

  • Posts: 1,272

    Hi Lionel, I'm glad it's working now! Have you tried stopping, starting, and seeing the status of the service?

    Regards,
    Luis.

  • Posts: 7

    Yes, it works now perfectly, thanks! : )

  • Posts: 1,272

    You're welcome, Lionel! :)

    Regards,
    Luis.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training