From b7c0a206863b8d030b2dcd1ac525ebe5bea4b7c6 Mon Sep 17 00:00:00 2001 From: Marco Hartmann Date: Sat, 28 Nov 2020 19:12:19 +0100 Subject: [PATCH] Show duration for which SLURM job has been running --- toolflow/scala/src/main/scala/tapasco/slurm/Slurm.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/toolflow/scala/src/main/scala/tapasco/slurm/Slurm.scala b/toolflow/scala/src/main/scala/tapasco/slurm/Slurm.scala index 81d56c06..3edb794a 100644 --- a/toolflow/scala/src/main/scala/tapasco/slurm/Slurm.scala +++ b/toolflow/scala/src/main/scala/tapasco/slurm/Slurm.scala @@ -32,6 +32,7 @@ import tapasco.filemgmt._ import tapasco.task.ResourceConsumer import tapasco.util.{Publisher, Template} +import scala.concurrent.duration.Duration import scala.collection.JavaConverters._ import scala.sys.ShutdownHookThread import scala.sys.process._ @@ -375,9 +376,12 @@ final object Slurm extends Publisher { /** Wait until the given SLURM job is not listed as RUNNING anymore in `sacct` output. */ def waitFor(id: Int): SlurmStatus = { val hook = ShutdownHookThread(Slurm.cancel(id)) + val start = System.currentTimeMillis() var status: SlurmStatus = Slurm.Running() while (status == Running()) { // can be cancelled by SIGINT - logger.info("SLURM job #%d is still running, sleeping for %d secs ...".format(id, slurmDelay / 1000)) + val dur = Duration(System.currentTimeMillis() - start, "millis") + logger.info("SLURM job #%d is running since %dh %02dm %02ds" + .format(id, dur.toHours, dur.toMinutes % 60, dur.toSeconds % 60)) Thread.sleep(slurmDelay) status = getSlurmStatus(id) }