![自 Ubuntu 22.04 升级以来,VNC 服务器无法正常工作](https://linux22.com/image/1188880/%E8%87%AA%20Ubuntu%2022.04%20%E5%8D%87%E7%BA%A7%E4%BB%A5%E6%9D%A5%EF%BC%8CVNC%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C.png)
我的服务器上运行着一些 TigerVNC 实例,用于远程访问。我将它们作为 systemd 服务启动。
自从升级到 Ubuntu 20.04 到 22.04 后,服务器无法启动并出现错误:
Session startup via '/home/VNC/.vnc/xstartup' cleanly exited too early (< 3 seconds)!
有人能给我指出正确的方向吗?
以下是我对服务的定义:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=VNC
PIDFile=/home/VNC/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i
ExecStart=/usr/bin/vncserver -localhost no -depth 24 -geometry 1920x1080 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
以下是我对 &HOME/.vnc/xstartup 的开始:
#!/bin/bash
xhost +
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XKL_XMODMAP_DISABLE=1
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
autocutsel -fork
startxfce4 &
我读了论坛上的一篇文章,其中谈到新的 vncserver 需要在前台运行,因此请从 startxfce4 命令中删除“&”。我这样做了,服务启动了。我可以从远程计算机访问,然而,大约 1 分钟后,服务停止并出现错误:Job for[电子邮件保护]由于超出超时而失败。
以下是 systemctl 状态:
VNC@HP-EliteDesk-800:~/.vnc$ systemctl status [email protected]
× [email protected] - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Mon 2022-08-22 10:31:01 MDT; 2min 40s ago
Process: 14603 ExecStartPre=/usr/bin/vncserver -kill :1 (code=exited, status=1/FAILURE)
Process: 14606 ExecStart=/usr/bin/vncserver -localhost no -depth 24 -geometry 1920x1080 :1 (code=exited, status=0/SUCCESS)
CPU: 4.972s
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Activating service name='org.gnome.evolution.dataserver.Calendar8' requested by ':1.25' (uid=1001 pid=14753 comm=>
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Activating service name='org.gtk.vfs.Metadata' requested by ':1.13' (uid=1001 pid=14730 comm="xfdesktop " label=">
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Successfully activated service 'org.gtk.vfs.Metadata'
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Successfully activated service 'org.gnome.evolution.dataserver.Calendar8'
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Activating service name='ca.desrt.dconf' requested by ':1.41' (uid=1001 pid=14941 comm="/usr/libexec/evolution-ca>
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Activating service name='org.gnome.evolution.dataserver.AddressBook10' requested by ':1.41' (uid=1001 pid=14941 c>
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Successfully activated service 'ca.desrt.dconf'
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Successfully activated service 'org.gnome.evolution.dataserver.AddressBook10'
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Activating service name='org.freedesktop.Tracker3.Miner.Extract' requested by ':1.26' (uid=1001 pid=14786 comm="/>
Aug 22 10:29:30 HP-EliteDesk-800 dbus-daemon[14633]: [session uid=1001 pid=14631] Successfully activated service 'org.freedesktop.Tracker3.Miner.Extract'