Systemd does not start my service automatically.
As soon as the process is stopped, the service also stops.
I noticed that the PID is not the same as the one displayed under systemctl status.
Is this because the type is set to forking?
My approach:
- Start VNC service (tigervnc)
- Establish VNC connection -> Logout
- After 10 seconds the service should be restarted.
root@debDev:~# systemctl enable --now tigervncserver@:3.service
Created symlink /etc/systemd/system/multi-user.target.wants/tigervncserver@:3.service → /lib/systemd/system/tigervncserver@.service.
root@debDev:~# systemctl status tigervncserver@:3.service
● tigervncserver@:3.service - Remote desktop service (VNC)
Loaded: loaded (/lib/systemd/system/tigervncserver@.service; enabled; preset: enabled)
Active: active (running) since Wed 2024-09-11 16:44:30 CEST; 6s ago
Process: 13577 ExecStart=/usr/libexec/tigervncsession-start :3 (code=exited, status=0/SUCCESS)
Main PID: 13584 (tigervncsession)
Tasks: 0 (limit: 9452)
Memory: 432.0K
CPU: 13ms
CGroup: /system.slice/system-tigervncserver.slice/tigervncserver@:3.service
‣ 13584 /usr/sbin/tigervncsession dev :3
Sep 11 16:44:30 debDev systemd[1]: Starting tigervncserver@:3.service - Remote desktop service (VNC)...
Sep 11 16:44:30 debDev tigervncsession[13584]: pam_unix(tigervnc:session): session opened for user dev(uid=1000) by (uid=0)
Sep 11 16:44:30 debDev systemd[1]: Started tigervncserver@:3.service - Remote desktop service (VNC).
root@debDev:~# systemctl status tigervncserver@:3.service
○ tigervncserver@:3.service - Remote desktop service (VNC)
Loaded: loaded (/lib/systemd/system/tigervncserver@.service; enabled; preset: enabled)
Active: inactive (dead) since Wed 2024-09-11 16:45:38 CEST; 29s ago
Duration: 1min 8.570s
Process: 13577 ExecStart=/usr/libexec/tigervncsession-start :3 (code=exited, status=0/SUCCESS)
Main PID: 13584 (code=exited, status=0/SUCCESS)
CPU: 13ms
Sep 11 16:44:30 debDev systemd[1]: Starting tigervncserver@:3.service - Remote desktop service (VNC)...
Sep 11 16:44:30 debDev tigervncsession[13584]: pam_unix(tigervnc:session): session opened for user dev(uid=1000) by (uid=0)
Sep 11 16:44:30 debDev systemd[1]: Started tigervncserver@:3.service - Remote desktop service (VNC).
Sep 11 16:45:38 debDev systemd[1]: tigervncserver@:3.service: Deactivated successfully.
As you can see above, even after 29s the vnc server has not been started.
Also the PIDs do not match.
..debDev:3.pid = 13609
xstartup:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
xrdb $HOME/.Xresources
xfce4-session
tigervncserver@.service:
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=dev
Group=dev
WorkingDirectory=/home/dev
Restart=always
RestartSec=10
PIDFile=/home/dev/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
Does anyone have an idea what the problem is?
How can I get it to work?