-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslurm_dir.sh
More file actions
executable file
·30 lines (22 loc) · 982 Bytes
/
slurm_dir.sh
File metadata and controls
executable file
·30 lines (22 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Check if the job ID is provided as a command-line argument
if [ $# -ne 1 ]; then
echo "Usage: $0 <job_id>"
return
fi
# Extract the job ID from the command-line argument
job_id_to_find="$1"
# job_info=$(scontrol show job $job_id_to_find | grep WorkDir)
# project_path=$(echo "$job_info" | sed 's/WorkDir=//') #$(echo "$job_info" | awk '{print $NF}')
sacct --starttime 2023-08-09 --format=User,JobID,Jobname%10,state,start,end,elapsed,nnodes,WorkDir%500 | grep "$USER $job_id_to_find"
job_info=$(sacct --starttime 2023-08-09 --format=User,JobID,WorkDir%500 | grep "$USER $job_id_to_find")
job_info=$(echo "$job_info" | sed s/$USER//)
job_info="${job_info#*[0-9] }"
project_path="${job_info// /}"
if [ -n "$project_path" ]; then
echo " cd project path for job ID $job_id_to_find: $project_path"
# Now, you can use 'cd' to change into the project path
cd ${project_path}
else
echo "Job ID $job_id_to_find not found in the Slurm output."
fi