How to attach to a running job to run top on compute node

To attach to a running job (job $JOBID)

srun --pty --jobid $JOBID /bin/bash

This will run inside the cgroup (CPU, RAM etc.) of the running job.

If you want to see the processes you can run top directly via

srun --pty --jobid $JOBID  top

For jobs with multiple nodes you need first find the node you want to attach to via

scontrol show job $JOBID |grep NodeList

Then use the -w switch to specify the node ($NODE)

srun --pty --jobid $JOBID -w $NODE /bin/bash
1 Like