while [ ! -f /tmp/.X${XDISPLAY}-lock ] do XDISPLAY=$((${XDISPLAY}+1)) /usr/X11R6/bin/Xvfb :${XDISPLAY} -screen 0 800x600x32 &>/dev/null & sleep 2 done If Xvfb has a problem that is unrecoverable, this will loop forever. Consider: # /usr/X11R6/bin/Xvfb :0 -screen 0 800x600x32 /usr/X11R6/bin/Xvfb: error while loading shared libraries: libpam.so.0: cannot open shared object file: No such file or directory The while loop should be clamped to some reasonable high value for ${XDISPLAY} and should error out if that value is reached. If the high value is reached, the output from Xvfb should be captured and displayed to the user in the error message, to give some clue as to what happened. I'd also recommend giving a starting value for ${XDISPLAY} as a largish number, and not 0, to lessen the chance of colliding with a used display.
I committed a fix for this.