# win\_scheduled\_task : run the scheduled task every minute

**URL:** <https://forum.ansible.com/t/win-scheduled-task-run-the-scheduled-task-every-minute/26741>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 14, 2018, 10:13pm UTC](https://forum.ansible.com/t/win-scheduled-task-run-the-scheduled-task-every-minute/26741 "2018-02-14T22:13:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktesr123456](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@ktesr123456](https://forum.ansible.com/u/ktesr123456)\
**Post date:** [February 14, 2018, 10:13pm UTC](https://forum.ansible.com/t/win-scheduled-task-run-the-scheduled-task-every-minute/26741/1 "2018-02-14T22:13:01Z")

</div>

Team,

Is there any option to run the scheduled task every minute. in the documentation i see the frequency is either once or daily or weekly

I am referring to “Advance Settings” from Trigger of Windows Scheduled task

Thanks.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [February 15, 2018, 6:13am UTC](https://forum.ansible.com/t/win-scheduled-task-run-the-scheduled-task-every-minute/26741/2 "2018-02-15T06:13:27Z")

</div>

In the latest release it isn’t possible to do with the current win\_scheduled\_task module. For 2.5 the module was drastically rewritten and supports this scenario, you can find the latest docs for it here [http://docs.ansible.com/ansible/devel/modules/win\_scheduled\_task\_module.html](http://docs.ansible.com/ansible/devel/modules/win_scheduled_task_module.html).

Using your example this is how it could possibly be done with the new format in 2.5

`

- name: create scheduled task to run every minute  
win\_scheduled\_task:  
name: task name here  
actions:
- path: cmd.exe  
arguments: /c echo hello world  
triggers:
- type: registration  
repetition:
- interval: PT1M  
duration: ‘’ # an empty value should mean it last infinitely

`

```auto

What this means is that a task that run "cmd.exe /c echo hello world" will create a registration trigger and run that every minute indefinitely. The registration trigger just means start the task on registration.

Thanks

Jordan

```

---

<div class="post-metadata">

**Author:** ![ktesr123456](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@ktesr123456](https://forum.ansible.com/u/ktesr123456)\
**Post date:** [February 15, 2018, 4:31pm UTC](https://forum.ansible.com/t/win-scheduled-task-run-the-scheduled-task-every-minute/26741/3 "2018-02-15T16:31:28Z")

</div>

Thanks Jordan,

We are still evaluating on moving to 2.5. Do we have any workaround in 2.0

Thanks.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [February 15, 2018, 9:11pm UTC](https://forum.ansible.com/t/win-scheduled-task-run-the-scheduled-task-every-minute/26741/4 "2018-02-15T21:11:34Z")

</div>

Not in any easy idempotent way unfortunately, you have some options, you could;

- Use win\_command/win\_shell to create the task but the COM API used can get quite complex and dealing with idempotency would be difficult
- You can copy the newer version of the module [https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/windows/win\_scheduled\_task.ps1](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/windows/win_scheduled_task.ps1) to a directory called library and use it like you would when 2.5 is out. It is best to name the module with a special suffix so you know that it is a custom version and not the builtin module used in Ansible.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![ktesr123456](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@ktesr123456](https://forum.ansible.com/u/ktesr123456)\
**Post date:** [February 16, 2018, 7:19pm UTC](https://forum.ansible.com/t/win-scheduled-task-run-the-scheduled-task-every-minute/26741/5 "2018-02-16T19:19:48Z")

</div>

Thanks Jordan i will go ahead with your suggestion
