# I want a task to fail if it takes longer than 2 hours to run

**URL:** <https://forum.ansible.com/t/i-want-a-task-to-fail-if-it-takes-longer-than-2-hours-to-run/30835>\
**Category:** Ansible Project\
**Created:** [July 22, 2019, 11:06am UTC](https://forum.ansible.com/t/i-want-a-task-to-fail-if-it-takes-longer-than-2-hours-to-run/30835 "2019-07-22T11:06:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![IP\_Freely](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@IP\_Freely](https://forum.ansible.com/u/IP_Freely)\
**Post date:** [July 22, 2019, 11:06am UTC](https://forum.ansible.com/t/i-want-a-task-to-fail-if-it-takes-longer-than-2-hours-to-run/30835/1 "2019-07-22T11:06:56Z")

</div>

I have a task that I need to run a command module for, but I need it to fail after a specific amount of time. I’m going to be using blocks so I can then move to recovery when it fails.  
what’s the best way of assigning a timeout to a task?

Many thanks in advance

John

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 22, 2019, 11:31am UTC](https://forum.ansible.com/t/i-want-a-task-to-fail-if-it-takes-longer-than-2-hours-to-run/30835/2 "2019-07-22T11:31:15Z")

</div>

With async  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_async.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html)
