一般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开始执行时,发送通知,然后脚本执行结束。ffinish是指当job结束时,发送通知,然后脚本执行结束。full是指当job的开始和结束时,都发送通知,期间会保持运行。

可以把send_notification函数的tokenuser替换为你自己的pushover api,或者整个函数替换为邮件通知等。

目前仅支持PBS job scheduler,即使用bjobs查看提交任务状态的调度器。可以修改代码的87-109行支持其他job scheduler。


文章版权归 FindHao 所有丨本站默认采用CC-BY-NC-SA 4.0协议进行授权|
转载必须包含本声明,并以超链接形式注明作者 FindHao 和本文原始地址:
https://findhao.net/easycoding/2583.html

Comments