How to use deletedir?

82 views
Skip to first unread message

James Johnson

unread,
Sep 6, 2012, 5:24:19 PM9/6/12
to skulker2...@googlegroups.com
I have a directory (/path/to/some/trash) that contains sub-directories of old stuff. I need to remove all but the most recent sub-directory from the parent. To do this, I've created the following rule:

        <rule
                n="1000"
                type="deletedir"
                interval="1D"
                match_type="directory"
                match_pattern="/path/to/some/trash/^.*$"
                match_pattern_limit="-1"
                match_pattern_limit_by="age"
        />

The rule correctly identifies the sub-directories to be deleted but refuses to delete them and logs the message:
   Directory /path/to/some/trash/1346933615523 [root:root] contains 11038 files - not deleting.

Digging through functions/deletedir.func, it appears that perform() is bailing out because of the 'if($fcount)' check. What do I need to do to force deletedir to remove the sub-directories even if they have children? I tried adding 'recurse=1' to 'type="deletedir"' but that did not help. I am using version skulker2,1-2-2,Linux.tarp.gz.

Simon Edwards

unread,
Sep 7, 2012, 4:19:25 AM9/7/12
to skulker2...@googlegroups.com

Just looked at code. Looks like a few tweaks are required. Will sort and test today.

--
You received this message because you are subscribed to the Google Groups "skulker2-discuss" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/skulker2-discuss/-/0R2SClen1eAJ.
To post to this group, send an email to skulker2...@googlegroups.com.
To unsubscribe from this group, send email to skulker2-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/skulker2-discuss?hl=en-GB.

Simon Edwards

unread,
Sep 7, 2012, 7:23:50 AM9/7/12
to skulker2...@googlegroups.com

Changes made. Will push code changes tonight.

On Sep 6, 2012 10:24 PM, "James Johnson" <jcejo...@gmail.com> wrote:

James Johnson

unread,
Sep 7, 2012, 12:06:27 PM9/7/12
to skulker2...@googlegroups.com
Thank you!

Simon Edwards

unread,
Sep 7, 2012, 5:29:42 PM9/7/12
to skulker2...@googlegroups.com
Hi James,
 The change I've made to be available from tonight as 1.2.3 is now explained....

Considering the following directory structure:

drwxr-xr-x 3 venture venture  4096 Sep  7 22:23 /tmp/simon
drwxr-xr-x 3 venture venture  4096 Sep  7 22:15 /tmp/simon/dir2
drwxr-xr-x 2 venture venture  4096 Sep  7 22:15 /tmp/simon/dir2/dir3
-rw-r--r-- 1 venture venture 16941 Sep  7 22:15 /tmp/simon/dir2/dir3/f1
-rw-r--r-- 1 venture venture 16941 Sep  7 22:15 /tmp/simon/dir2/dir3/f2
-rw-r--r-- 1 venture venture 16879 Sep  7 22:15 /tmp/simon/dir2/f4

And the following rule:

<rule
n="20"
type="deletedir"
match_type="directory"
match_pattern="/tmp/simon/dir2"
/>

Because the directory is not empty the following error will be shown:

2012/09/07 22:24:28 LOG      Directory /tmp/simon/dir2 [venture:venture] not empty (3 files, 1 directories) but no recurse option set - not deleting.

However if the rule is changed to use the recurse option:

    <rule
        n="20"
        type="deletedir recurse=true"
        match_type="directory"
        match_pattern="/tmp/simon/dir2"
    />

Then instead we get:

2012/09/07 22:27:05 LOG    Rule simon:20   Rule action     : deletedir recurse=true
2012/09/07 22:27:05 LOG                    Match type      : directory
2012/09/07 22:27:05 LOG                    Match pattern   : /tmp/simon/^dir2$
2012/09/07 22:27:05 LOG                    Match by        : ALWAYS
2012/09/07 22:27:05 LOG                    Run interval    : 0D
2012/09/07 22:27:05 LOG                    Last run        : 2012/09/07 22:24
2012/09/07 22:27:05 LOG                    Last run info   : Files: 0  Duration: 00:00:00  Space: 0.0 Kb
2012/09/07 22:27:05 LOG                    Last scan info  : Files: 0  Directories: 2  Duration: 00:00:00
2012/09/07 22:27:05 LOG      Delete file /tmp/simon/dir2/f4 [venture:venture, 16.48 Kb, 0 Days]
2012/09/07 22:27:05 LOG      Delete file /tmp/simon/dir2/dir3/f2 [venture:venture, 16.54 Kb, 0 Days]
2012/09/07 22:27:05 LOG      Delete file /tmp/simon/dir2/dir3/f1 [venture:venture, 16.54 Kb, 0 Days]
2012/09/07 22:27:05 LOG      Deleted directory /tmp/simon/dir2/dir3 [venture:venture]
2012/09/07 22:27:05 LOG      Deleted directory /tmp/simon/dir2 [venture:venture]
2012/09/07 22:27:05 LOG    Scanned 0 files in 2 directories [00:00:00].
2012/09/07 22:27:05 LOG    Processed 1 file in 1 directory.

Which should be exactly what you expect the deletedir to do!

Regards,
Simon.

--
You received this message because you are subscribed to the Google Groups "skulker2-discuss" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/skulker2-discuss/-/uy4EMegszssJ.

James Johnson

unread,
Sep 11, 2012, 9:08:28 AM9/11/12
to skulker2...@googlegroups.com
Hi Simon,

Sorry for the long delay. I've been testing in our environment for the last couple of days and the modification is working great. Thanks for the quick response!

rku...@fordham.edu

unread,
Sep 27, 2017, 3:45:34 PM9/27/17
to skulker2-discuss
Does this work with symbolic links? For example:

lrwxrwxrwx 1 myuser staff   54 Jul 25 12:29 C-myuser-101-1501000145_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-101-1501000145_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   54 Sep  8 16:30 C-myuser-139-1504902632_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-139-1504902632_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   54 Sep  8 13:52 C-myuser-141-1504893128_stDMATE_dp32 -> /tmp/.x2go-myuser/C-myuser-141-1504893128_stDMATE_dp32

lrwxrwxrwx 1 myuser staff   54 Sep  8 15:35 C-myuser-141-1504899338_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-141-1504899338_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   54 Sep 25 11:28 C-myuser-150-1506353278_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-150-1506353278_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   53 Jun 27 11:26 C-myuser-50-1498577188_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-50-1498577188_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   53 Jun 27 11:27 C-myuser-50-1498577243_stDMATE_dp32 -> /tmp/.x2go-myuser/C-myuser-50-1498577243_stDMATE_dp32

lrwxrwxrwx 1 myuser staff   53 Jul 10 09:28 C-myuser-50-1499693297_stDMATE_dp32 -> /tmp/.x2go-myuser/C-myuser-50-1499693297_stDMATE_dp32

lrwxrwxrwx 1 myuser staff   53 May 16 13:59 C-myuser-52-1494957538_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-52-1494957538_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   53 May 12 10:47 C-myuser-64-1494600433_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-64-1494600433_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   53 May 26 13:56 C-myuser-94-1495821367_stDMATE_dp32 -> /tmp/.x2go-myuser/C-myuser-94-1495821367_stDMATE_dp32

lrwxrwxrwx 1 myuser staff   53 Jul  1 10:02 C-myuser-94-1498917747_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-94-1498917747_stDXFCE_dp32

lrwxrwxrwx 1 myuser staff   53 Jul  2 00:37 C-myuser-94-1498970274_stDXFCE_dp32 -> /tmp/.x2go-myuser/C-myuser-94-1498970274_stDXFCE_dp32

drwxr-xr-x 2 myuser staff 4096 Sep 27 13:48 ssh



                n="1000"

                type="deletedir recurse=true"

                match_type="directory"

                match_pattern="/u/myuser/\.x2go"

                match_by="MTIME > 1D"


2017/09/27 15:38:51 LOG    Rule hostonly-mydomain:1000   Rule action     : deletedir recurse=true

2017/09/27 15:38:51 LOG                                               Match type      : directory

2017/09/27 15:38:51 LOG                                               Match pattern   : /u/myuser/^\.x2go$

2017/09/27 15:38:51 LOG                                               Match by        : MTIME > 1D

2017/09/27 15:38:51 LOG                                               Run interval    : 0h

2017/09/27 15:38:51 LOG                                               Last run        : 2017/09/27 15:37

2017/09/27 15:38:51 LOG                                               Last run info   : Files: 0  Duration: 00:00:00  Space: 0.0 Kb

2017/09/27 15:38:51 LOG                                               Last scan info  : Files: 0  Directories: 2  Duration: 00:00:00

2017/09/27 15:38:51 LOG       Calling set_run for hostonly-mydomain / 1000

2017/09/27 15:38:51 LOG    Scanned 0 files in 2 directories [00:00:00].

2017/09/27 15:38:51 LOG    Processed 0 files in 0 directories.

Simon Edwards

unread,
Sep 27, 2017, 4:36:14 PM9/27/17
to skulker2...@googlegroups.com
Hi James,
I will reply in more detail tomorrow morning GMT.  I really need to push out another release too. The code has had some improvements and bug fixes since it was last made public.

I will also reply with an answer about deleting directories in this scenario too.

Regards,
Simon.

To unsubscribe from this group and stop receiving emails from it, send an email to skulker2-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to skulker2-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/skulker2-discuss.
For more options, visit https://groups.google.com/d/optout.

rku...@fordham.edu

unread,
Sep 28, 2017, 1:51:04 PM9/28/17
to skulker2-discuss
Hi Simon,

I actually replied to the thread :-).

Do any of the XML files already handle temporary files created by vi such as results from this type of find command?

find ~ -type f \( -name '*.swp' -o -name '*~' -o -name '*.bak' -o -name '.netrwhist' \)

Also on page 94 of the config PDF, there's a reference to "TYPE "
The type of file system object that the current “file” is - will be set to any of the following: 
f file 
d directory 
c Character device 
b Block device 
s UNIX domain socket 
l Symbolic Link 
p Named pipe

Does that mean "l" can be used in a config?

Thanks for replying!

Rob
To unsubscribe from this group and stop receiving emails from it, send an email to skulker2-discu...@googlegroups.com.
To post to this group, send email to skulker2...@googlegroups.com.

rku...@fordham.edu

unread,
Oct 6, 2017, 11:24:10 AM10/6/17
to skulker2-discuss
Any update on this?
To unsubscribe from this group and stop receiving emails from it, send an email to skulker2-discu...@googlegroups.com.
To post to this group, send email to skulker2...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages