Access task's submission time in its job script

Hello,

I have a use case for which it would be useful to know, in a task’s job script or in its prescript, the wall-clock time at which the task was submitted to the scheduler. Is this possible in cylc (8.3.5)?

Any help would be greatly appreciated!

Hi @jlentz,

The easiest way to get job submit time from within the job itself, I think, would be to read the job.status file that is written automatically by every Cylc job, in the job log directory on the job host.

(You can print job status files with cylc cat-log -f s, or look in the task log directory).

Conveniently, the file content looks like bash-format variable assignments already, so you can simply eval the lot. Example:

[scheduling]
    [[graph]]
        R1 = foo
[runtime]
    [[foo]]
        script = """
            eval $(cat "${CYLC_TASK_LOG_DIR}/job.status")
            echo "My submit time is $CYLC_JOB_RUNNER_SUBMIT_TIME"
        """

Result:

$ cylc cat-log test//1/foo

Workflow : test/run22
Job : 1/foo/01 (try 1)
User@Host: oliver@slayer.local

My submit time is 2025-05-01T07:12:45+12:00

2025-05-01T07:12:46+12:00 INFO - started
2025-05-01T07:12:46+12:00 INFO - succeeded

Thanks very much for the answer Hilary!

I have one follow-up question. What I’m really interested in is the time at which all of the present task’s dependencies have completed (for which I believe the submission time should be a good proxy). Is it correct to assume that the job file (in the present task’s CYLC_TASK_LOG_DIR) is always created after all the dependencies have completed?

No, the job file is written at the last moment just before job submission.

Job submit time may not be a good proxy for dependencies getting satisfied if:

  • you have any Cylc queues actively limiting job submissions
  • or if the subprocess pool, which handles job submission, event handlers, etc., is rammed

If you really want the time at which the last dependency was satisfied you’ll need to scrape the scheduler log for completion of the associated outputs, or query the same in the scheduler run database (sqlite) - both on the scheduler host, not the job host (if they differ).