Recursive delete select files more than 60 days old

12 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Bob

ungelesen,
28.08.2015, 16:58:3328.08.15
an help-cfengine
I've made a few attempts at this, but it's not working.  I have a structure like this:

/srv/data/dataset1
/srv/data/test1_prog1_123
/srv/data/test2_prog1_5442
/srv/data/test3_prog1_123
/srv/data/test4_prog2_6773

I need to get rid of the stuff with .*_prog1_.* and .*_prog2_.* in it, but leave the other stuff.  Here's my last attempt:

bundle agent sitemain
{
vars:
      "prog_logs" slist => { ".*_prog1_.*/.*", ".*_prog2_.*/.*" };

files:
  data_sys::
    "/srv/data"
    delete        => tidy,
    file_select   => name_age("@(sitemain.prog_logs)", "60"),
    depth_search => recurse("inf");
}


The issue is nothing is being removed. Here's what I see in the log:

cf3>  ->>  Entering /srv/data/test1_prog1_123 (0)

but never any deletes.

Neil Watson

ungelesen,
28.08.2015, 18:42:4728.08.15
an help-cfengine
Note enough data provided. But, leaf name only matches the file node, not
the directories. Also, your regexes are far to loose and greedy. Tighten
them up and test with pcregrep or gnu grep -P.

--
Neil H Watson
Sr. Partner, Architecture and Infrastructure
CFEngine reporting: https://github.com/evolvethinking/delta_reporting
CFEngine policy: https://github.com/evolvethinking/evolve_cfengine_freelib
CFEngine and vim: https://github.com/neilhwatson/vim_cf3
CFEngine support: http://evolvethinking.com

Ted Zlatanov

ungelesen,
08.09.2015, 13:25:0708.09.15
an help-c...@googlegroups.com
On Fri, 28 Aug 2015 13:58:33 -0700 (PDT) Bob <buha...@gmail.com> wrote:

B> I've made a few attempts at this, but it's not working. I have a structure
B> like this:

B> /srv/data/dataset1
B> /srv/data/test1_prog1_123
B> /srv/data/test2_prog1_5442
B> /srv/data/test3_prog1_123
B> /srv/data/test4_prog2_6773

B> I need to get rid of the stuff with .*_prog1_.* and .*_prog2_.* in it, but
B> leave the other stuff.

You could build the slist of such files with findfiles()

https://docs.cfengine.com/latest/reference-functions-findfiles.html

So `/srv/data/test/*_prog[12]_*` might work for you.

Ted

Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten