Skip to content

Instantly share code, notes, and snippets.

@whophil

whophil/sge-tools.sh

Last active Jan 19, 2017
Embed
What would you like to do?
Bash scripts for making life with Sun Grid Engine (SGE) easier.
#!/bin/sh
#
# A collection of bash functions for working with SGE.
#
# Installation
# ------------
# Install at the command prompt
# $ . /path/to/sge-goto.sh
#
# Or, add this line to your ~/.bashrc
# . /path/to/sge-goto.sh
function qgoto() {
# Go to the working directory of a Sun Grid Engine job with a specified job ID.
#
# Usage
# -----
# $ qgoto [job_id]
#
# Example
# -------
# $ qgoto 23892
DIR=$(qstat -j $1 | grep sge_o_workdir | awk '{print $2}')
cd "$DIR"
}
function qlog() {
# Echo the stdout file of a Sun Grid Engine job with a specified job ID.
#
# Usage
# -----
# $ qlog [job_id]
#
# Example
# -------
# $ qlog 23892
#
# To show the last 200 lines:
# $ qlog 23902 | tail -200
LOGFILE=$(qstat -j $1 | grep stdout_path_list | awk -F ':' {'print $NF'} | sed -e 's/$JOB_ID/'$1'/g')
LOGFILE=$(echo $LOGFILE | sed -e 's|$HOME|'$HOME'|g')
cat $LOGFILE
}
function qerr() {
# Echo the stderr file of a Sun Grid Engine job with a specified job ID.
#
# Usage
# -----
# $ qerr [job_id]
#
# Example
# -------
# $ qerr 23892
#
# To show the last 200 lines:
# $ qerr 23982 | tail -200
LOGFILE=$(qstat -j $1 | grep stderr_path_list | awk -F ':' {'print $NF'} | sed -e 's/$JOB_ID/'$1'/g')
LOGFILE=$(echo $LOGFILE | sed -e 's|$HOME|'$HOME'|g')
cat $LOGFILE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment