一般HPC集群都会有任务调度系统,比如PBS或者LSF。这些调度系统会默认内置job的开始和结束邮件通知,但是不好用,甚至管理员可能并没有提供相应的实现。由于消息通知对于我来说是一个比较普遍的需求,不只是在HPC job调度上,且之前购买了pushover的服务,于是写了一个简单的任务监听工具。
usage: notify.py [-h] [-i The process id] -m s|start: when the status of
target process becomes running, it sends notification. It is
default mode. f|finish: when the target process finished, it
sends notification. full: start + finish
-i
参数指定进程的id
-m
指定监听的模式。s
或者 start
是指当job开始执行时,发送通知,然后脚本执行结束。f
或finish
是指当job结束时,发送通知,然后脚本执行结束。full
是指当job的开始和结束时,都发送通知,期间会保持运行。
可以把send_notification
函数的token
和user
替换为你自己的pushover api,或者整个函数替换为邮件通知等。
目前仅支持PBS job scheduler,即使用bjobs
查看提交任务状态的调度器。可以修改代码的87-109行支持其他job scheduler。
Comments