1
0
Fork 0
mirror of https://github.com/hcartiaux/dotfiles.git synced 2024-10-18 17:25:23 +02:00
dotfiles/bash/bash_slurm

17 lines
697 B
Bash
Executable file

# Job + Remaining time
__slurm_ps1_remaining_time(){
if [ -n "$SLURM_JOB_ID" ]; then
DATE_NOW=$(date +%s)
DATE_JOB_START=$(stat -c %Y "/sys/fs/cgroup/cpu/slurm/uid_${UID}/job_${SLURM_JOB_ID}")
[[ -z "$TIME_LIMIT" ]] && TIME_LIMIT=$(scontrol show job $SLURM_JOB_ID | grep -Po 'TimeLimit=\K[^ ]*' | awk -F: '/:/ { print ($1 * 3600) + ($2 * 60) + $3 }')
((DATE_TMP = (TIME_LIMIT - DATE_NOW + DATE_JOB_START) / 60))
echo -n "[SLURM$SLURM_JOB_ID->$DATE_TMP]"
fi
}
[[ -n "$INTERACTIVE" && -n "$SLURM_PTY_PORT" ]] && (
echo "[SLURM] SLURM_JOB_ID=$SLURM_JOB_ID"
echo "[SLURM] Your nodes are:"
srun bash -c 'echo " $(hostname)*$SLURM_CPUS_ON_NODE"' | sort -u
) || true