Nyxynyx
Nyxynyx

Reputation: 63647

Xvfb failed to start when running second screen

Two scripts first.sh and second.sh are to be used to run test.sh and test2.sh headlessly using Xvfb on Ubuntu 16.04.

Problem: After running first.sh, we get an error when we run second.sh.

xvfb-run: error: Xvfb failed to start

What went wrong and how can we fix it? Thanks!

first.sh

#/bin/sh

# Clean Process Space:
kill -9 `pidof xvfb-run`
kill -9 `pidof java`
kill -9 `pidof Xvfb`

# Launch a virtual screen
Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null &
export DISPLAY=:1

# Launch the script
xvfb-run "/home/me/test.sh" &

history -c

second.sh

#/bin/sh

# Launch a virtual screen
Xvfb :2 -screen 0 1024x768x24 2>&1 >/dev/null &
export DISPLAY=:2

# Launch the script
xvfb-run "/home/me/test2.sh" &

history -c

Upvotes: 2

Views: 3453

Answers (1)

Thiago
Thiago

Reputation: 91

Include the option -a to your command line, like:

xvfb-run -a "/home/me/test2.sh"

The option is a shortage for --auto-servernum which tries to find a free server number before opening it.

Upvotes: 1

Related Questions