Is there a pattern which I can use when finding my file which contains date and timestamp. The format of my file is file_name.file_extension.processID.YYYY-MM-DD@HH:MM:SS~
My variables
findFile
- "home/usr/file1"
- "home/usr/file2"
- "home/usr/file3/file4"
- "home/usr/file5"
My playbook role
- name: Find files
find:
paths: "{{ item }}"
patterns:
- '*.*.*.*.*@*~'
age: 30d
recurse: yes
register: fileList
loop: "{{ findFile }}"
- name: Delete files
file:
path: "{{ item.path }}"
state: absent
loop: "{{ fileList.files }}"
This is the sample file and directory
home
|-------usr
|-------file1
|-------configFile.xml
|-------file2
|-------propertiesFile.txt.2012.2020-07-13@23:08:10~
|-------file3
|-------file4
|-------content.yml.2012.2020-04-04@23:08:10~
|-------file5
|-------configFile.xml.2012.2020-03-05@13:08:10~