# how to execute a handler  if a file is found

**URL:** <https://forum.ansible.com/t/how-to-execute-a-handler-if-a-file-is-found/32976>\
**Category:** Ansible Project\
**Created:** [May 19, 2020, 7:29pm UTC](https://forum.ansible.com/t/how-to-execute-a-handler-if-a-file-is-found/32976 "2020-05-19T19:29:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Idar](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@Dan\_Idar](https://forum.ansible.com/u/Dan_Idar)\
**Post date:** [May 19, 2020, 7:29pm UTC](https://forum.ansible.com/t/how-to-execute-a-handler-if-a-file-is-found/32976/1 "2020-05-19T19:29:32Z")

</div>

Hello

I would like to be able to find the files that are bigger than a certain dize and then restart a service if this happens because it mean the rotation is not working after the configurtion update

the find module does not ‘change’ when the file is found or not and i know i can trigger a change using  
`when_changed: true`

per instance:

`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 19, 2020, 7:33pm UTC](https://forum.ansible.com/t/how-to-execute-a-handler-if-a-file-is-found/32976/2 "2020-05-19T19:33:34Z")

</div>

Maybe something like this:

- name: find files  
find:  
path: /var/log  
patterns: ‘\*.log’  
size: 100m  
register: bigfiles  
changed\_when: bigfiles.files !=   
notify: start service

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 19, 2020, 8:46pm UTC](https://forum.ansible.com/t/how-to-execute-a-handler-if-a-file-is-found/32976/3 "2020-05-19T20:46:36Z")

</div>

Ansible would also be a great tool to prevent breakage like "rotation  
is not working after configuration update" from occurring in the first  
place.  
You might want to fix that, at some point.
