How long has my Cylc task been running?

Hi there

I currently have a suite with the running tasks as listed in the attached screenshot.

What’s the easiest way of finding out how long each task has been running for?




The easiest option is probably to open the Cylc GUI in the “tree view” and sort by the start time. Doesn’t really give you the run time but does make it easy to pick out long running tasks.

Otherwise for more advanced analysis the information you need is in the database. This quick script will list all running tasks along with their calculated run time:


echo 'task|cycle|run-time'

while IFS= read -r line; do
    if [[ -n "$line" ]]; then
        start_time="$(cut -d '|' -f 3 <<< "${line}")"
        run_time="$(isodatetime "${start_time}" now)"
        sed "s/${start_time}/${run_time}/" <<< "${line}"
done <<< $(sqlite3 \
    "${HOME}/cylc-run/generic/log/db" \
    'SELECT name, cycle, time_run FROM task_jobs WHERE time_run IS NOT NULL AND time_run_exit IS NULL')
1 Like

Thanks a lot for that! I put that in a script called howlongcylc and ran it but it hung (hence the control+c, ^C below). I got a permission denied error for some reason, even though I own it.

> ./howlongcylc
task|cycle|run-time|Mon Dec 09|21:17:29|scripts> ./howlongcylc: line 15: /home/williamsjh/cylc-run/u-bo721/log/db: Permission denied
> ls -l /home/williamsjh/cylc-run/u-bo721/log/db
-rw-rw-r--+ 1 williamsjh niwa00013 983040 Dec  9 21:06 /home/williamsjh/cylc-run/u-bo721/log/db

Hi Jonny,

I wonder if you didn’t copy over the line continuation characters properly from Oliver’a script - are they in your script just as above and with no trailing whitespace? From your error message, it looks like you’re trying to execute the db file as if it were command (rather than pass it as an input parameter to the sqlite3 command as intended).


1 Like

Ah, yup! Thanks Hilary.

I’m now getting this different error…

> ./howlongcylc
./howlongcylc: line 8: isodatetime: command not found

Is isodatetime a different utility that I need to install or point to?

Thanks again


The isodatetime command is quite recent so it might not be in your installation, however, it is really just the old rose date command which we rebranded and moved into isodatetime.

1 Like

OK awesome, thanks. It now works when I replace isodatetime with rose date. :smiley:

The script is on GitHub here.

One more thing though, if you look at the output below, what are the final entries in the lines? They seem to be random numbers?..|Wed Dec 11|23:09:11|scripts> howlongcylc
coupled|20080101T0000Z|PT7H27M21,0659780502S|Wed Dec 11|23:09:34|scripts> howlongcylc
coupled|20080101T0000Z|PT7H27M30,3806409836S|Wed Dec 11|23:09:43|scripts> howlongcylc
coupled|20080101T0000Z|PT7H28M33,6980140209S|Wed Dec 11|23:10:46|scripts> howlongcylc
coupled|20080101T0000Z|PT7H28M35,2833590508S|Wed Dec 11|23:10:48|scripts> howlongcylc



If you mean the bit after the comma that’s the decimal second.

So in this example:


That’s a period of:

  • 7 hours
  • 29 minutes
  • 50.6736791134 seconds

I think you can change the output format to get rid of this unnecessary precision.

Hey Oliver

Thanks a lot for that. I wasn’t aware that that level of precision was even possible in these circumstances.

All the best


I think the precision comes from the isodatetime now.

1 Like

OK awesome, thanks Oliver and Hilary too!