CFD Online Discussion Forums

CFD Online Discussion Forums (
-   CFX (
-   -   cfx5post in batch mode on "graphics-less" Linux (

frankyd April 8, 2011 17:48

cfx5post in batch mode on "graphics-less" Linux
I am getting the following error "cannot connect to X server" while running "cfx5post -batch xxx.cse" from command line. The OS is RHEL 4 and has no graphics card, and thereby the DISPLAY environment variable is not set. I have also tried "cfx5post -batch xxx.cse -graphics mesa" without success.

Does cfx5post need a graphics display while running in batch mode???

Frank D.

mjgraf April 10, 2011 21:16

unfortunately yes.
the way we got around this to run all our macros in batch mode was to create a virtual frame buffer.

Install xvfb
configure (even suggest to create an init.d script so it starts all the time).
Ensure you set a reasonable resolution and color depth.

then use the -display # switch for cfxpost.

If I recall, it stems from Qt and some quick of its system.

mjgraf April 12, 2011 11:26

Found my documentation
Detailed for Suse, but should be similar for RH.

Xvfb is a virtual frame buffer to create an X display.


  1. Install Xvfb as part of YAST package: xorg-x11-server-extra
  2. Create the X auth file: /etc/Xvfb.auth
  3. Create the boot script: /etc/init.d/xvfb
  4. Make the new script executable: chmod +x /etc/init.d/xvfb
  5. Create symlink: ln -s /etc/init.d/xvfb /usr/sbin/rcxvfb
  6. Enable the init script: insserv /etc/init.d/xvfb
  7. Start the service: rcxvfb start

  • The X Auth file should only contain 'localhost'
  • One can dryrun insserv: insserv -n -v /etc/init.d/xvfb
  • insserv ensures that the new init scripts loads correctly
  • Check the init script for more info

Boot script

Xvfb script

Xvfb Settings
Display Number: 71
X Auth File: /etc/Xvfb.auth
Screen Setting: screen 0 2048x2048x24
Memory Mapped File: /tmp/Xvfb_screen0
Log File: /var/log/Xvfb_X71.log
Lock File: /tmp/.X71-lock


# /etc/init.d/xvfb
#  and its symbolic link
# /usr/sbin/rcxvfb
# Provides:          Xvfb
# Required-Start:    network nfs
# Should-Start:
# Required-Stop:    network
# Should-Stop:
# Default-Start:    3 5
# Default-Stop:
# Short-Description: Xvfb daemon, provides virtual frame buffer
# Description:      Start Xvfb
#    Primarily used for batch processing because
#    CFX and Ansys require an X Display.

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
test -x $XVFB_BIN || { echo "$XVFB_BIN not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi; }

# Decided not to source a config file
# Left the code just incase
# Check for existence of needed config file and read it
#test -r $XVFB_CONFIG || { echo "$XVFB_CONFIG not existing";
#    if [ "$1" = "stop" ]; then exit 0;
#    else exit 6; fi; }
# Read config

# The auth file is a plain text file with only "localhost" listed.
test -r $XVFB_AUTHFILE || { echo "$XVFB_AUTHFILE not existing";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 7; fi; }
XVFB_SCREEN="-screen 0 2048x2048x24"

# Shell functions sourced from /etc/rc.status:
#      rc_check        check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v    be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s    display "skipped" and exit with status 3
#      rc_status -u    display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset        clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

# Reset status of this service

case "$1" in
    echo -n "Starting Xvfb on DISPLAY=:$XVFB_DISPLAY"
    # Remove the old log file
    rm -f $XVFB_LOG
    ## Start daemon with startproc(8). If this fails
    ## the return value is set appropriately by startproc.
    /sbin/startproc -l $XVFB_LOG $XVFB_BIN $XVFB_ARGS

    # Remember status and be verbose
    rc_status -v
    echo -n "Shutting down Xvfb "
    ## Stop daemon with killproc(8) and if this fails
    ## killproc sets the return value according to LSB.

    /sbin/killproc -TERM $XVFB_BIN

    # Remember status and be verbose
    rc_status -v
    ## Stop the service and regardless of whether it was
    ## running or not, start it again.
    $0 stop
    $0 start

    # Remember status and be quiet
    echo -n "Checking for service Xvfb "
    ## Check status with checkproc(8), if process is running
    ## checkproc will return with exit status 0.

    # Return value is slightly different for the status command:
    # 0 - service up and running
    # 1 - service dead, but /var/run/  pid  file exists
    # 2 - service dead, but /var/lock/ lock file exists
    # 3 - service not running (unused)
    # 4 - service status unknown :-(
    # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)

    # NOTE: checkproc returns LSB compliant status values.
    /sbin/checkproc $XVFB_BIN
    # NOTE: rc_status knows that we called this init script with
    # "status" option and adapts its messages accordingly.
    rc_status -v
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1

frankyd April 12, 2011 16:47

Thanks mjgraf!

Using xvfb-run (wrapper around xvfb) solved the problem.

Frank D.

All times are GMT -4. The time now is 14:41.