# How to get timestamps from every play?

**URL:** <https://forum.ansible.com/t/how-to-get-timestamps-from-every-play/39469>\
**Category:** Get Help\
**Created:** [January 6, 2025, 8:25am UTC](https://forum.ansible.com/t/how-to-get-timestamps-from-every-play/39469 "2025-01-06T08:25:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpeckov](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mpeckov](https://forum.ansible.com/u/mpeckov)\
**Post date:** [January 6, 2025, 8:25am UTC](https://forum.ansible.com/t/how-to-get-timestamps-from-every-play/39469/1 "2025-01-06T08:25:02Z")

</div>

How do I get timestamps from every task that runs? Ideally I’d like a timestamp to show in the line with all the \* showing the task name, but getting it on the following line would work.

I haven’t found a way to do it (and see this ask for the exact same thing in 2014: [Including timestamps in PLAY [host] \*\*\* messages](https://forum.ansible.com/t/including-timestamps-in-play-host-messages/15987)) and so what I am doing is inserting tasks between all of mine that are just:

```auto
    - name: TimeStamp # noqa: no-changed-when
      delegate_to: localhost
      ansible.builtin.shell:
        echo "TimeStamp:`date +'%Y%m%d-%H%M%S'`"

```

This a horrible way to do it, but I haven’t found any other options. I want to know when each task starts, so that I have some indication how long the previous one took.

Some example output that I currently have looks like this:

```auto
TASK [TimeStamp] *******************************************************************************************************************
changed: [localhost] => {"changed": true, "cmd": "echo \"TimeStamp:`date +'%Y%m%d-%H%M%S'`\"", "delta": "0:00:00.007684", "end": "2024-12-30 18:05:39.135224", "msg": "", "rc": 0, "start": "2024-12-30 18:05:39.127540", "stderr": "", "stderr_lines": [], "stdout": "TimeStamp:20241230-180539", "stdout_lines": ["TimeStamp:20241230-180539"]}

TASK [Create subnet] ***************************************************************************************************************
ok: [localhost] => {"changed": false, "state": {"address_prefix": "10.100.40.0/24", "address_prefixes": null, "id": "/subscriptions/<redacted>/resourceGroups/BuildPool0/providers/Microsoft.Network/virtualNetworks/BuildPool0/subnets/BuildPool0", "name": "BuildPool0", "nat_gateway": null, "network_security_group": {"id": "/subscriptions/<redacted>/resourceGroups/BuildPool0/providers/Microsoft.Network/networkSecurityGroups/BuildPool0", "name": "BuildPool0", "resource_group": "BuildPool0"}, "private_endpoint_network_policies": "Enabled", "private_link_service_network_policies": "Enabled", "provisioning_state": "Succeeded", "route_table": {}}}

TASK [TimeStamp] *******************************************************************************************************************
changed: [localhost] => {"changed": true, "cmd": "echo \"TimeStamp:`date +'%Y%m%d-%H%M%S'`\"", "delta": "0:00:00.007216", "end": "2024-12-30 18:05:41.422159", "msg": "", "rc": 0, "start": "2024-12-30 18:05:41.414943", "stderr": "", "stderr_lines": [], "stdout": "TimeStamp:20241230-180541", "stdout_lines": ["TimeStamp:20241230-180541"]}

TASK [Create VMSS] *****************************************************************************************************************

```

I’d like to the timestamp in the line showing the task name…like this:

```auto
TASK [Create subnet] [2024-12-30 18:05:39.127540] ******************************************
ok: [localhost] => {"changed": false, "state": {"address_prefix": "10.100.40.0/24", "address_prefixes": null, "id": "/subscriptions/<redacted>/resourceGroups/BuildPool0/providers/Microsoft.Network/virtualNetworks/BuildPool0/subnets/BuildPool0", "name": "BuildPool0", "nat_gateway": null, "network_security_group": {"id": "/subscriptions/<redacted>/resourceGroups/BuildPool0/providers/Microsoft.Network/networkSecurityGroups/BuildPool0", "name": "BuildPool0", "resource_group": "BuildPool0"}, "private_endpoint_network_policies": "Enabled", "private_link_service_network_policies": "Enabled", "provisioning_state": "Succeeded", "route_table": {}}}

TASK [Create VMSS] [2024-12-30 18:05:41.414943] ******************************************

```

Since the output shows start and end times, it is available when the task is shell…just put the start time in the task header line please. And, since I’m asking for something that doesn’t seem to exist, I’d like the ability to format the timestamp output as well, to fit my standards.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [January 6, 2025, 10:38am UTC](https://forum.ansible.com/t/how-to-get-timestamps-from-every-play/39469/2 "2025-01-06T10:38:25Z")

</div>

Hi, perhaps [this callback plugin](https://docs.ansible.com/ansible/latest/collections/community/general/timestamp_callback.html) ?

---

<div class="post-metadata">

**Author:** ![mpeckov](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mpeckov](https://forum.ansible.com/u/mpeckov)\
**Post date:** [January 11, 2025, 12:07am UTC](https://forum.ansible.com/t/how-to-get-timestamps-from-every-play/39469/3 "2025-01-11T00:07:32Z")

</div>

That looks awesome, and looks like it will let me do what I want.

However, the problem is, if some user or system isn’t properly setup, it doesn’t work. It’s a per-user configuration rather than something that core ansible does. I’d like to guarantee that it shows on every run regardless of who runs it or what system it is run from.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 11, 2025, 1:48pm UTC](https://forum.ansible.com/t/how-to-get-timestamps-from-every-play/39469/4 "2025-01-11T13:48:12Z")

</div>

> [@mpeckov](#):
>
> However, the problem is, if some user or system isn’t properly setup, it doesn’t work

I’m unsure what this means exactly? What setup is required?

I assume you have you have added the plugin to the `ansible.cfg` file? See [setting a callback plugin for `ansible-playbook`](https://docs.ansible.com/ansible/latest/plugins/callback.html#id4).
