
前面介绍了作业的提交,下面我们介绍一下如何查看作业的状态。查看作业状态的方式有多种,Slurm提供了多个命令行工具,包括scontrol,squeue,sstat,sview等等都可以查看作业状态,不过由于我们暂时还没介绍到交互作业和作业步(sstat),可视化(sview)也不是我们关心的重点,我们先只介绍scontrol和squeue查看作业状态。
如果只是讲这两个命令的使用的话,就大可不必单独写一篇文章来赘述了,我们要关注的核心是状态对应的具体含义。不过在开始之前我们还是先简单介绍一下如何使用这两个命令行工具。
命令行工具
scontrol
通过scontrol show job [jobid]可以查看作业(或指定jobid的作业)的详细状态。

可以看到输出了非常多的信息,包括节点状态、优先级、资源需求、作业时间、运行的节点、输出文件等等。如果希望输出的内容更方便解析,可以加上--oneliner参数,则会按行以空格分割的键值对形式输出。

squeue
scontrol输出的信息非常完整,不过缺点是效率较低,如果系统中存在大量的作业,该命令的输出响应速度则会变得非常慢,而有时候我们并不需要那么详细的信息,如果只是查看作业的状态的话,squeue则是更好的选择

作业状态
每个作业的执行过程中通常要经历多个状态,典型的作业状态包括PENDING, RUNNING, SUSPENDED, COMPLETING和COMPLETED。
作业的生命周期
对于一个作业而言,从提交到结束,有一个状态转换的过程,用流行的说法,我们也可以称之为作业的生命周期。下图是我整理的一个作业状态转换图:

状态对照表
下面是所有可能出现的作业状态对应的编码以及其含义解释
| 编码缩写(Short code) | 状态名(State) | 英文含义 (meaning) | 中文翻译 |
|---|---|---|---|
| BF | BOOT_FAIL | Job terminated due to launch failure, typically due to a hardware failure (e.g. unable to boot the node or block and the job can not be requeued). | 作业由于启动失败而终止,通常是由于硬件故障。 |
| CA | CANCELLED | Job was explicitly cancelled by the user or system administrator. The job may or may not have been initiated. | 作业被用户或系统管理员终止,该作业可能已经启动或者没有启动。 |
| CD | COMPLETED | Job has terminated all processes on all nodes with an exit code of zero. | 作业包含的每个进程在所有节点上都已结束且没有出现问题。 |
| CF | CONFIGURING | Job has been allocated resources, but are waiting for them to become ready for use (e.g. booting). | 作业已经被分配资源,正在等待所有资源准备就绪。 |
| CG | COMPLETING | Job is in the process of completing. Some processes on some nodes may still be active. | 作业正在完成中。某些节点上的某些进程可能仍然是活动的。 |
| F | FAILED | Job terminated with non-zero exit code or other failure condition. | 非零退出码结束或其他错误导致的作业终止。 |
| NF | NODE_FAIL | Job terminated due to failure of one or more allocated nodes. | 作业由于一个或多个分配的节点的故障而终止。 |
| PD | PENDING | Job is awaiting resource allocation. | 正在等待资源分配。 |
| PR | PREEMPTED | Job terminated due to preemption. | 作业由于资源被抢占而终止。 |
| RV | REVOKED | Sibling was removed from cluster due to other cluster starting the job. | 作业已转移到其他集群上。 |
| R | RUNNING | Job currently has an allocation. | 作业正在运行中。 |
| SE | SPECIAL_EXIT | The job was requeued in a special state. This state can be set by users, typically in EpilogSlurmctld, if the job has terminated with a particular exit value. | 特殊状态下的重新排队,该状态通常是由用户配置的EpilogSlurmctld设置的。 |
| ST | STOPPED | Job has an allocation, but execution has been stopped with SIGSTOP signal. CPUS have been retained by this job. | 作业已经分配运行,但执行过程由于接收到SIGSTOP信号而停止,该作业将继续保有已分配的CPU。 |
| S | SUSPENDED | Job has an allocation, but execution has been suspended and CPUs have been released for other jobs. | 作业在执行过程中被挂起,所分配的资源将被释放用于其他作业。 |
| TO | TIMEOUT | Job terminated upon reaching its time limit. | 工作在达到期限后终止。 |