1

Im trying to write a systemd script which starts Xvfb in the background.

Doing this in the console is no problem of course with appended "&".

But i tried to write a systemd script and when im starting it manually with

service xvfb start

it seems that its never send to the background as there is never a prompt after running this command.

This is the script:

[Unit]
Description=Xvfb
After=tomcat.service

[Timer]
# Time to wait after booting before we run first time
OnBootSec=1min

[Service]
Type=forking
User=test
Group=test

ExecStart=/usr/bin/Xvfb :99
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

Do i need maybe to use another type?

3
  • Maybe you should change service type. Try to use simple instead of forking. More information about types you can find here
    – mrc02_kr
    Aug 31, 2017 at 12:38
  • type forked produces the same result...
    – StephanM
    Aug 31, 2017 at 13:31
  • 1
    You should use simple not forking. Also you should start systemd service using systemctl start <srv> not service <srv> start.
    – mrc02_kr
    Aug 31, 2017 at 13:37

1 Answer 1

3
Type=forking

Is for processes that fork and background themselves - aka old style daemons. This causes systemd to wait for the process to background itself exit and to keep track of the child process vis pid files or other means. Your application never exits so systemd continues to wait.

Instead you should use

Type=simple

for application that do not background themselves. This causes systemd daemon to keep track of the process, but return immediately from systemctl effectively backgrounding it for you. Simple is the default type so you can omit the Type flag altogether if you wish.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .