# \[Urgent help\] Running a task every x seconds till y seconds

**URL:** <https://forum.ansible.com/t/urgent-help-running-a-task-every-x-seconds-till-y-seconds/27161>\
**Category:** Ansible Developer\
**Created:** [March 30, 2018, 9:31am UTC](https://forum.ansible.com/t/urgent-help-running-a-task-every-x-seconds-till-y-seconds/27161 "2018-03-30T09:31:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akash\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Akash\_Agarwal](https://forum.ansible.com/u/Akash_Agarwal)\
**Post date:** [March 30, 2018, 9:31am UTC](https://forum.ansible.com/t/urgent-help-running-a-task-every-x-seconds-till-y-seconds/27161/1 "2018-03-30T09:31:11Z")

</div>

Hi All,

I there a way to run a task every x seconds, store the output. The task should run till y second. Example, I would like to run a task every 10 seconds , get the output , till 300 seconds. So the task would be run 30 times and all 30 outputs are avilable

Thanks,  
Akash

---

<div class="post-metadata">

**Author:** ![lambda\_111](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@lambda\_111](https://forum.ansible.com/u/lambda_111)\
**Post date:** [April 4, 2018, 8:49am UTC](https://forum.ansible.com/t/urgent-help-running-a-task-every-x-seconds-till-y-seconds/27161/2 "2018-04-04T08:49:52Z")

</div>

Hi

You can achieve this as follows

- hosts: localhost  
tasks:
- include: action.yml  
with\_items:
- 1
- 2
- 3

in action.yml

- name: “Wait for 10 seconds”  
wait\_for: timeout=10

- name: “run task after 10 seconds”  
command: uptime
