# How to find out job run time?

**URL:** <https://cylc.discourse.group/t/how-to-find-out-job-run-time/675>\
**Category:** Cylc Support\
**Created:** [June 21, 2023, 1:05am UTC](https://cylc.discourse.group/t/how-to-find-out-job-run-time/675 "2023-06-21T01:05:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Edkins](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/nick_edkins/32/267_2.png) [@Nick\_Edkins](https://cylc.discourse.group/u/Nick_Edkins)\
**Post date:** [June 21, 2023, 1:05am UTC](https://cylc.discourse.group/t/how-to-find-out-job-run-time/675/1 "2023-06-21T01:05:04Z")

</div>

Hi,

I’m playing around with the number of processors to find the best balance of quick submission time and quick run time for various total run lengths. I need to know the time I submitted each job, the time it ended, and ideally how long it took between submission and starting. Is there a simple way to do this?

Cheers!

---

<div class="post-metadata">

**Author:** ![jonnyhtw](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtw/32/232_2.png) [@jonnyhtw](https://cylc.discourse.group/u/jonnyhtw)\
**Post date:** [June 21, 2023, 2:44am UTC](https://cylc.discourse.group/t/how-to-find-out-job-run-time/675/2 "2023-06-21T02:44:36Z")

</div>

as discussed in person 🙂 i know you can get this from the beginning and end of the `job.out` file but it would really good to know if there is an easier/automated way of doing this!

cheers

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [June 21, 2023, 5:01am UTC](https://cylc.discourse.group/t/how-to-find-out-job-run-time/675/3 "2023-06-21T05:01:42Z")

</div>

You can extract that timing info from the workflow run database - an sqlite DB in the workflow log directory):

```console
$ sqlite3 -header ~/cylc-run/demo/runN/log/db "select * from task_jobs"
cycle|name|submit_num|flow_nums|is_manual_submit|try_num|time_submit|time_submit_exit|submit_status|time_run|time_run_exit|run_signal|run_status|platform_name|job_runner_name|job_id
1|data|1|[1]|0|1|2023-06-21T16:57:37+12:00|2023-06-21T16:57:38+12:00|0|2023-06-21T16:57:38+12:00|2023-06-21T16:57:49+12:00||0|localhost|background|10513
1|build-model|1|[1]|0|1|2023-06-21T16:57:37+12:00|2023-06-21T16:57:38+12:00|0|2023-06-21T16:57:38+12:00|2023-06-21T16:57:48+12:00||0|localhost|background|10512
2|data|1|[1]|0|1|2023-06-21T16:57:37+12:00|2023-06-21T16:57:38+12:00|0|2023-06-21T16:57:38+12:00|2023-06-21T16:57:57+12:00||0|localhost|background|10515
3|data|1|[1]|0|1|2023-06-21T16:57:50+12:00|2023-06-21T16:57:51+12:00|0|2023-06-21T16:57:51+12:00|2023-06-21T16:58:03+12:00||0|localhost|background|10625
4|data|1|[1]|0|1|2023-06-21T16:57:51+12:00|2023-06-21T16:57:51+12:00|0|2023-06-21T16:57:52+12:00|2023-06-21T16:58:07+12:00||0|localhost|background|10660
5|data|1|[1]|0|1|2023-06-21T16:57:59+12:00|2023-06-21T16:57:59+12:00|0|2023-06-21T16:58:00+12:00|2023-06-21T16:58:15+12:00||0|localhost|background|10701
1|model_m2|1|[1]|0|1|2023-06-21T16:58:05+12:00|2023-06-21T16:58:05+12:00|0|2023-06-21T16:58:06+12:00|2023-06-21T16:58:22+12:00||0|localhost|background|10742
1|model_m1|1|[1]|0|1|2023-06-21T16:58:09+12:00|2023-06-21T16:58:09+12:00|0|2023-06-21T16:58:10+12:00|2023-06-21T16:58:26+12:00||0|localhost|background|10783
1|model_m3|1|[1]|0|1|2023-06-21T16:58:17+12:00|2023-06-21T16:58:17+12:00|0|2023-06-21T16:58:18+12:00|2023-06-21T16:58:33+12:00||0|localhost|background|10839
1|post1_m2|1|[1]|0|1|2023-06-21T16:58:23+12:00|2023-06-21T16:58:23+12:00|0|2023-06-21T16:58:24+12:00|2023-06-21T16:58:40+12:00||0|localhost|background|10890
1|post1_m1|1|[1]|0|1|2023-06-21T16:58:27+12:00|2023-06-21T16:58:27+12:00|0|2023-06-21T16:58:28+12:00|2023-06-21T16:58:39+12:00||0|localhost|background|10931
1|post2_m2|1|[1]|0|1|2023-06-21T16:58:35+12:00|2023-06-21T16:58:35+12:00|0|2023-06-21T16:58:36+12:00|2023-06-21T16:58:48+12:00||0|localhost|background|10977
1|post2_m1|1|[1]|0|1|2023-06-21T16:58:40+12:00|2023-06-21T16:58:40+12:00|0|2023-06-21T16:58:41+12:00||||localhost|background|11024
2|model_m2|1|[1]|0|1|2023-06-21T16:58:40+12:00|2023-06-21T16:58:41+12:00|0|2023-06-21T16:58:41+12:00||||localhost|background|11059
1|post1_m3|1|[1]|0|1|2023-06-21T16:58:49+12:00|2023-06-21T16:58:50+12:00|0|||||localhost|background|11105
...

```

---

<div class="post-metadata">

**Author:** ![dpmatthews](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/dpmatthews/32/26_2.png) [@dpmatthews](https://cylc.discourse.group/u/dpmatthews)\
**Post date:** [June 21, 2023, 6:17am UTC](https://cylc.discourse.group/t/how-to-find-out-job-run-time/675/4 "2023-06-21T06:17:46Z")

</div>

> [@jonnyhtw](#):
>
> i know you can get this from the beginning and end of the `job.out` file

You can also look in the `job.status` file which is easier to parse or source. e.g.

```auto
#!/bin/bash
. job.status
echo "Start time: $CYLC_JOB_INIT_TIME"
echo "End time: $CYLC_JOB_EXIT_TIME"
echo "Elapsed: $(( $(date -d "$CYLC_JOB_EXIT_TIME" +%s) - $(date -d "$CYLC_JOB_INIT_TIME" +%s) )) s"

```

Example output:

```auto
Start time: 2023-05-09T10:00:26Z
End time: 2023-05-09T10:02:56Z
Elapsed: 150 s

```

---

<div class="post-metadata">

**Author:** ![oliver.sanders](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/oliver.sanders/32/110_2.png) [@oliver.sanders](https://cylc.discourse.group/u/oliver.sanders)\
**Post date:** [June 21, 2023, 1:54pm UTC](https://cylc.discourse.group/t/how-to-find-out-job-run-time/675/5 "2023-06-21T13:54:43Z")

</div>

Also see:

- The `cylc report-timings` command.
- The analysis view in the Cylc GUI.
