Skip to content

Instantly share code, notes, and snippets.

@willfurnass
Created April 19, 2017 14:44
Show Gist options
  • Save willfurnass/10277756070c4f374e6149a281324841 to your computer and use it in GitHub Desktop.
Save willfurnass/10277756070c4f374e6149a281324841 to your computer and use it in GitHub Desktop.
Simple wrapper for Sun Grid Engine's qrsh that propagates SGE environment variables and enables X forwarding
#!/bin/sh
# David Jones and Will Furnass (University of Sheffield)
# `qrsh` is often the most convenient utility for starting interactive shell
# sessions on Sun/Son of Grid Engine (SGE) clusters but it has some limitations (as
# configured on the ShARC/Iceberg clusters):
#
# - none of the standard SGE environment vars (e.g. JOB_ID, PE_HOSTFILE,
# NSLOTS) that are defined in qsub/qsh batch/interactive sessions are set
# (annoying but not the end of the world);
# - variables can't be set in prolog scripts (e.g. the CUDA_VISIBLE_DEVICES env
# var needed for exclusively locking GPUs to jobs);
# - X display forwarding doesn't work.
#
# This script addresses these three issues. It starts a qrsh shell session in
# which:
#
# - all environment variables set by the scheduler (e.g. JOB_ID) are set
# - X display forwarding is enabled if necessary
exec qrsh $( [ -z ${DISPLAY+x} ] || echo '-v DISPLAY' ) -pty y "$@" $SHELL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment