From 69b607b4ed91342366e5fcbff62fd0802ab72cf4 Mon Sep 17 00:00:00 2001
From: Jafaruddin Lie <jafar.lie@monash.edu>
Date: Fri, 16 Mar 2018 16:36:19 +1100
Subject: [PATCH] updated slurm epilog for X clean up

Former-commit-id: 1cd8192184ed0160e914e659795a2bb07c3f32ae
---
 roles/slurm-common/templates/slurm.epilog.j2 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/roles/slurm-common/templates/slurm.epilog.j2 b/roles/slurm-common/templates/slurm.epilog.j2
index 0c059ae6..cf17eceb 100644
--- a/roles/slurm-common/templates/slurm.epilog.j2
+++ b/roles/slurm-common/templates/slurm.epilog.j2
@@ -6,6 +6,24 @@ find /tmp -user ${SLURM_JOB_USER} -name ".esd-*" | xargs rm -rf
 find /tmp -user ${SLURM_JOB_USER} -name ".X*-lock" | xargs rm -rf
 find /tmp/.X11-unix -user ${SLURM_JOB_USER} -name "X*" | xargs rm -rf
 
+# NOTE: 20180316 The jobs above clean up the VNC session
+# further clean up for Strudel Session
+# X lock files are owned by root, so we need to find the right files to delete
+
+
+# New Strudel session will create a file under user's home folder called xorg-jobid
+# This file contains the display number that is assigned to xterm when it starts
+
+# Assigning variable and trimming the : from the display number
+XSESSION=`cat /home/${SLURM_JOB_USER}/.vnc/xorg-${SLURM_JOB_ID} | tr -d :`
+
+# Formatting the filenames for the two files that we need to clean: /tmp/.X*-lock and /tmp/.X11/X*
+XLOCKFILENAME=".X"$XSESSION"-lock"
+XUNIXFILENAME="X"$XSESSION
+
+# Find the files and delete them
+find /tmp/ -name $XLOCKFILENAME -exec rm -rf {} \;
+find /tmp/.X11-unix -name $XUNIXFILENAME -exec rm -rf {} \;
 
 # echo 1 to drop page cache
 /bin/sync
-- 
GitLab