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:

/etc/systemd/system$ cat vncserver@.service 
[Unit]
Description=Remote desktop service (VNC) on port :%I
After=syslog.target network.target

[Service]
Type=forking
User=username

ExecStartPre=-/usr/bin/vncserver -kill :%i
ExecStart=/usr/bin/vncserver  :%i  -localhost
PIDFile=/home/username/.vnc/%H:%i.pid
ExecStop=-/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

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

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

Commenting out the both lines:

 # ExecStartPre=-/usr/bin/vncserver -kill :%i
 # 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!

Comments

  • luisviveropena
    luisviveropena Posts: 1,249

    Hi @LioC ,

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

    Regards,
    Luis.

  • LioC
    LioC 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.

  • luisviveropena
    luisviveropena Posts: 1,249

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

    Regards,
    Luis.

  • LioC
    LioC Posts: 7

    Yes, it works now perfectly, thanks! : )

  • luisviveropena
    luisviveropena Posts: 1,249

    You're welcome, Lionel! :)

    Regards,
    Luis.

Categories

Upcoming Training