Forum: CFEngine Help
Subject: recursive file operation based on directory characteristics
Author: davidlee
Link to topic: https://cfengine.com/forum/read.php?3,25980,25980#msg-25980
(cfengine community 3.1.4; RHEL 5.x)
Each day, we make a small subtree of a few files and directories, asking
cfengine to preserve the timestamps on the original files ("stealth"). That's
working fine.
We are only interested in these for about a week, then we want to remove them.
So I'm looking for a cfengine mechanism to say "if the directory is older than
seven days, recursively remove it and its contents".
But there is a problem which I cannot see how to solve. Some files within
recent (i.e. NOT to be removed) directories have old timestamps (because of the
original "stealth"). So when I try something like:
"$(parentdir)/.*/."
delete => tidy,
file_select => days_old("7"),
depth_search => recurse("inf"),
it descends into even recent (younger than 7 days) directories and removes
those apparently old files. This is not what we want.
What we need is (I think!):
if the matched directory is younger than 7 days
then
skip altogther
else
recursively remove (regardless any date on any subfile/subdir)
fi
How can I avoid it descending into recent directories? Have I overlooked
something obvious in the manual?
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine