Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm following this tutorial, and I want to know the equivalent centos-version of this ubuntu-specific step:

You may receive a few warnings regarding fonts and such, but it’ll still work despite these. If you want the framebuffer to start automatically on system startup you can do:
sudo update-rc.d xvfb defaults 10

What's the proper way to start xvfb on startup on centos?

share|improve this question

2 Answers 2

up vote 12 down vote accepted

I use the following init script to add and start xvfb on boot just blat that in /etc/init.d/ and run chkconfig xvfb on

   #!/bin/bash
   #chkconfig: 345 95 50
   #description: Starts xvfb on display 99
   if [ -z "$1" ]; then
   echo "`basename $0` {start|stop}"
       exit
   fi

   case "$1" in
   start)
       /usr/bin/Xvfb :99 -screen 0 1280x1024x24 &
   ;;

   stop)
       killall Xvfb
   ;;
   esac
share|improve this answer
1  
dont forget add execute permission to this file: chmod +x xvfb –  panchicore Jan 21 '13 at 23:54
1  
Even though his question was posed for CentOS, it has become useful for other distributions, too. This works well on Ubuntu; you just need to run update-rc.d instead of chkconfig. See this answer for more information on update-rc.d. –  sigpwned Oct 18 '13 at 23:48

Here's a nice init script to accomplish this:

http://onemoretech.wordpress.com/2009/05/27/an-xvfb-init-script/

The script is:

#!/bin/bash
#
# /etc/rc.d/init.d/xvfbd
#
# chkconfig: 345 95 28
# description: Starts/Stops X Virtual Framebuffer server
# processname: Xvfb
#

. /etc/init.d/functions

[ "${NETWORKING}" = "no" ] && exit 0

PROG="/usr/X11R6/bin/Xvfb"
PROG_OPTIONS=":5 -screen 0 640x480x24"
PROG_OUTPUT="/tmp/Xvfb.out"

case "$1" in
    start)
        echo -n "Starting : X Virtual Frame Buffer "
        $PROG $PROG_OPTIONS>>$PROG_OUTPUT 2>&1 &
        disown -ar
        /bin/usleep 500000
        status Xvfb & >/dev/null && echo_success || echo_failure
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
            /bin/touch /var/lock/subsys/Xvfb
            /sbin/pidof -o  %PPID -x Xvfb > /var/run/Xvfb.pid
        fi
        echo
        ;;
    stop)
        echo -n "Shutting down : X Virtual Frame Buffer"
        killproc $PROG
        RETVAL=$?
        [ $RETVAL -eq 0 ] && /bin/rm -f /var/lock/subsys/Xvfb
 /var/run/Xvfb.pid
        echo
        ;;
    restart|reload)
        $0 stop
        $0 start
        RETVAL=$?
        ;;
    status)
        status Xvfb
        RETVAL=$?
        ;;
    *)
     echo $"Usage: $0 (start|stop|restart|reload|status)"
     exit 1
esac

exit $RETVAL

Save the script as xvfbd and copy the script to /etc/init.d, then run the following command:

sudo chkconfig --add xvfbd
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.