Skip to content
Snippets Groups Projects
slurm.epilog.j2 1.26 KiB
Newer Older
Trung Nguyen's avatar
Trung Nguyen committed
#!/bin/sh

# specific files to be deleted to clean up after a Strudel session
find /tmp -user ${SLURM_JOB_USER} -name "pulse*" | xargs rm -rf
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 {} \;

# Now we clean up
rm -rf /home/${SLURM_JOB_USER}/.vnc/xorg-${SLURM_JOB_ID}

# echo 1 to drop page cache
/bin/sync
/bin/echo 1 > /proc/sys/vm/drop_caches

exit 0