3

Vivid switched from upstart to systemd. I used to have xfvb configured to run as a service under updstart. That has now broken.

Under upstart, I had /etc/init/xvfb.conf:

description     "Xvfb X Server"
start on (net-device-up
    and local-filesystems
    and runlevel [2345])
stop on runlevel [016]
exec /usr/bin/Xvfb :99 -screen 0 1024x768x24

and I could start it with sudo service xvfb start

Under 15.04, I now get this message when I try to use service to start xvfb:

Failed to start xvfb.service: Unit xvfb.service failed to load: No such file or directory.

What is the new way to configure xvfb to run as a service with systemd?

1

1 Answer 1

8

Under systemd you create /etc/systemd/system/xvfb.service

[Unit]
Description=X Virtual Frame Buffer Service
After=network.target

[Service] 
ExecStart=/usr/bin/Xvfb :99 -screen 0 1024x768x24

[Install]
WantedBy=multi-user.target

And then run

sudo systemctl enable /etc/systemd/system/xvfb.service

At which point

sudo service xvfb start

will start it:

$ ps -elfwww | grep -i Xvfb
4 S root      7807     1  2  80   0 - 51102 poll_s 16:47 ?        00:00:00 /usr/bin/Xvfb :99 -screen 0 1024x768x24

and

sudo service xvfb stop

will kill it

3
  • You could also point out what sudo systemctl status xvfb.service will show. Also note that you could templatize on the display name and have xvfb@:99.service instead.
    – JdeBP
    May 9, 2015 at 9:45
  • Your answer here superuser.com/a/912648/183672 gives the complete example without the hardcoded :99 that allows multiple screens to be started as a service. May 9, 2015 at 11:08
  • 1
    You could also add Restart=always and RestartSec=3 under [Service] to make Xvfb restart in case it went down for some reason.
    – mihaic
    Jan 31, 2017 at 20:07

You must log in to answer this question.

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