Busybox Find & mtime option

I want to use the command find to delete files over a certain date from a FTP directory on the router (these are CCTV recordings so take up a fair bit of room on my external drive). My plan was to use the find command in a cron script thus: find ‘/mnt/data/ftp_root/cctv/’ -type f -mtime +3 -delete

The version of find in Busybox on the router appears to not have the -mtime option included? (I haven’t tried the -delete option yet as I didn’t want to delete everything in that dir!)

BusyBox v1.25.1 (2017-09-13 19:43:58 CEST) multi-call binary.

Usage: find [-HL] [PATH]… [OPTIONS] [ACTIONS]

Search for files and perform actions on them.
First failed action stops processing of current file.
Defaults: PATH is current directory, action is ‘-print’

    -L,-follow      Follow symlinks
    -H              ...on command line only
    -xdev           Don't descend directories on other filesystems
    -maxdepth N     Descend at most N levels. -maxdepth 0 applies
                    actions to command line arguments only
    -mindepth N     Don't act on first N levels
    -depth          Act on directory *after* traversing it

( ACTIONS ) Group actions for -o / -a
! ACT Invert ACT’s success/failure
ACT1 [-a] ACT2 If ACT1 fails, stop, else do ACT2
ACT1 -o ACT2 If ACT1 succeeds, stop, else do ACT2
Note: -a has higher priority than -o
-name PATTERN Match file name (w/o directory name) to PATTERN
-iname PATTERN Case insensitive -name
-path PATTERN Match path to PATTERN
-ipath PATTERN Case insensitive -path
-regex PATTERN Match path to regex PATTERN
-type X File type is X (one of: f,d,l,b,c,…)
-perm MASK At least one mask bit (+MASK), all bits (-MASK),
or exactly MASK bits are set in file’s mode
-user NAME/ID File is owned by given user
-group NAME/ID File is owned by given group
-size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))
+/-N: file size is bigger/smaller than N
-prune If current file is directory, don’t descend into it
If none of the following actions is specified, -print is assumed
-print Print file name
-print0 Print file name, NUL terminated
-exec CMD ARG ; Run CMD with all instances of {} replaced by
file name. Fails if CMD exits with nonzero

Though the busybox command help shows it should be there!

Am I doing something wrong or is this a software issue not spotted yet?

You’re not doing anything wrong. It’s just compiled without that feature: https://gitlab.labs.nic.cz/turris/openwrt/blob/test/package/utils/busybox/Config-defaults.in#L988

1 Like

I personally think that Turris (all versions) can afford much more featureful configuration of busybox. AFAIK the main downside would be size and that’s very small now (400 kiB), compared to the builtin storage and RAM.


Is there any (easy) way how to avoid busybox version of “find” command and install full version of this command? I am also missing “mtime” filter in the busybox version.

It seems the full find is not present in any package listed in “opkg list”.