2

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
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

1 Answers1

1

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.

Thiago
  • 81
  • 10