# SLURM job info in context

**URL:** <https://discourse.openondemand.org/t/slurm-job-info-in-context/1479>\
**Category:** Get Help\
**Created:** [May 11, 2021, 7:29pm UTC](https://discourse.openondemand.org/t/slurm-job-info-in-context/1479 "2021-05-11T19:29:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpuerto-psc](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jpuerto-psc/32/590_2.png) [@jpuerto-psc](https://discourse.openondemand.org/u/jpuerto-psc)\
**Post date:** [May 11, 2021, 7:29pm UTC](https://discourse.openondemand.org/t/slurm-job-info-in-context/1479/1 "2021-05-11T19:29:27Z")

</div>

Good Afternoon,

Looking to get a bit of feedback to see if anyone has attempted this before. Essentially, what I am trying to do is get information from the SLURM job (groupID and userID) within the context of script.sh.erb for jupyter\_lab.

Not sure if OOD already has the slurm job info somewhere in the context.

Thanks in advance!

Juan

---

<div class="post-metadata">

**Author:** ![jpuerto-psc](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jpuerto-psc/32/590_2.png) [@jpuerto-psc](https://discourse.openondemand.org/u/jpuerto-psc)\
**Post date:** [May 12, 2021, 2:01pm UTC](https://discourse.openondemand.org/t/slurm-job-info-in-context/1479/2 "2021-05-12T14:01:17Z")

</div>

Good Morning All,

Was able to resolve this issue (using SLURM environment variables). However, I am encountering a different issue now.

SLURM seems to ignore the clean.sh script that I’ve added to the templates/ directory. It seems that the task gets _scancelled_ prior to the clean.sh script running. I think the appropriate solution here is to use the SLURM epilogue to do our clean up instead. Wondering where I should be setting that to make sure that the sbatch command (run by OOD to start the jupyter process) runs.

Thanks in advance!

Juan

---

<div class="post-metadata">

**Author:** ![jeff.ohrstrom](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jeff.ohrstrom/32/136_2.png) [@jeff.ohrstrom](https://discourse.openondemand.org/u/jeff.ohrstrom)\
**Post date:** [May 13, 2021, 2:16pm UTC](https://discourse.openondemand.org/t/slurm-job-info-in-context/1479/3 "2021-05-13T14:16:25Z")

</div>

Hey, sorry for the delay. I’m not super sure how to install SLURM epilogues if that’s your question.

If the question is how to determine in the epilogue that it was an OnDemand jupyter job, I think an epilogue is the right place. You can use the `SLURM_JOB_NAME` to determine if it’s a jupyter job (ours is `ondemand/sys/dashboard/sys/bc_osc_jupyter`) and take the necessary actions based on that. And `SLURM_SUBMIT_HOST` to be double sure.

---

<div class="post-metadata">

**Author:** ![jpuerto-psc](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jpuerto-psc/32/590_2.png) [@jpuerto-psc](https://discourse.openondemand.org/u/jpuerto-psc)\
**Post date:** [May 13, 2021, 5:16pm UTC](https://discourse.openondemand.org/t/slurm-job-info-in-context/1479/4 "2021-05-13T17:16:33Z")

</div>

Jeff,

Thanks for your response here. As you can imagine, parsing through every job submitted isn’t ideal for us. It seems that srun allows you to submit a _task_ specific epilog. The same is not true for sbatch unfortunately.

Do you know how other users happen to handle this? My other thought here would be using trap to catch the signal. This seems to work fine when a user **quits** jupyter notebook, but not when a user **deletes** the session (which issues an scancel from SLURM).

Best,

Juan

---

<div class="post-metadata">

**Author:** ![westburg.2](https://avatars.discourse-cdn.com/v4/letter/w/0ea827/32.png) [@westburg.2](https://discourse.openondemand.org/u/westburg.2)\
**Post date:** [May 26, 2022, 3:42pm UTC](https://discourse.openondemand.org/t/slurm-job-info-in-context/1479/5 "2022-05-26T15:42:56Z")

</div>


