Configure xvfb for Vivid (15.04) as a service using systemd


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

Description=X Virtual Frame Buffer Service

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


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


sudo service xvfb stop

will kill it


Related videos on Youtube

Stephen Ostermiller
Author by

Stephen Ostermiller

Contact Me Website GitHub Facebook LinkedIn

Updated on September 18, 2022


  • Stephen Ostermiller
    Stephen Ostermiller almost 2 years

    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?

  • JdeBP
    JdeBP about 9 years
    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.
  • Stephen Ostermiller
    Stephen Ostermiller about 9 years
    Your answer here gives the complete example without the hardcoded :99 that allows multiple screens to be started as a service.
  • mihaic
    mihaic over 7 years
    You could also add Restart=always and RestartSec=3 under [Service] to make Xvfb restart in case it went down for some reason.