任何作业完成后,SLURM是否可以触发脚本(由前端-SLURM用户实现)?

时间:2017-04-17 09:54:41

标签: slurm

我们知道SLURM可以在作业完成后发送电子邮件。

除此之外,类似于工作完成时的邮寄机制:

[问] SLURM在任何作业完成后是否可以触发脚本(由前端-SLURM用户实现)?

示例解决方案:这会强制我让while()检查并等待提交的作业完成。这可能会占用额外的CPU使用量。

jobID=$(sbatch -U user -N1 run.sh | cut -d " " -f4-);
job_state=$(sacct -j $jobID --format=state  | tail -n1 | head -n1)
while [ $job_state != $completed ]
do
    job_state=$(sacct -j $jobID --format=state  | tail -n1 | head -n1)
done
my_script.sh//When any job completed I want SLURM to trigger my_script.sh if possible.

请那样说:我被告知每1秒检查一次可能效率低下。 Is doing `while ps -p $PID; do sleep 1; ` until a script is completed efficient?

感谢您宝贵的时间和帮助。

1 个答案:

答案 0 :(得分:2)

选项是(ab)使用@Path("/db") @Produces(MediaType.APPLICATION_JSON) public class StudentService implements StudentServiceInterface{ static StudentDao data= new StudentDaoImpl(); @Override public Response getStudents(){ GenericEntity<List<Student>> entity = new GenericEntity<List<Student>>(data.getAllStudents()){}; return Response.ok(entity).build(); } @Override public Response getStudent(@PathParam("id") int id){ return Response.ok(data.getStudent(id)).build(); } @Override public Response addStudent(Student stu) { data.addStudent(stu); return Response.ok(stu).build(); } } 中的MailProg选项。它最初是指用于在完成作业时向用户发送电子邮件的程序的完全限定路径。但该计划可以做任何其他事情。它通过命令行参数接收作业ID和一些其他信息。

因此您可以使用slurm.conf配置slurm。您需要确保客户端添加MailProg=/path/to/my_script.sh选项,或者通过作业提交插件自动添加。

脚本可以具有以下结构(未经测试):

--mail-type

脚本将从Slurm参数中收到如下:

#!/bin/bash

# First to the wanted behaviour
jobid=$(echo $2 | cut -d= -f2 | cut -d' ' -f 1|cut -d_ -f1)
event=$(echo $2 | awk 'print $4')

case $event in
Started)
    job_startup_script $jobid 
    ;; 
Ended|Failed|TIMEOUT)
    job_end_script $jobid
    ;; 
esac

# Then send the email to get the usual behaviour
/bin/mail "$@"

如果脚本SLURM Job_id=<Job-ID> Name=<JobName> <Status>, Run time <RunTime> 很长,请使用job_startup_script启动它,并使用&符号(nohup)使其成为后台进程。

还要确保所有脚本都可由&

读取和执行
相关问题