Finding files older than x days on a system with a stripped down busybox
Clash Royale CLAN TAG#URR8PPP
up vote
9
down vote
favorite
I need to find and delete files older than 1 week in the Development unit. There are limited number utilities available on this unit. -mtime
find
's predicate is not available. How do I check all files which are older than x days in this case?
linux files find date busybox
 |Â
show 5 more comments
up vote
9
down vote
favorite
I need to find and delete files older than 1 week in the Development unit. There are limited number utilities available on this unit. -mtime
find
's predicate is not available. How do I check all files which are older than x days in this case?
linux files find date busybox
2
It is unclear what you mean with "mtime
is not available". It's not a utility whose name I recognise.
â Kusalananda
Aug 21 at 9:35
/path/to/my/folder$ find -type f -mtime +7 delete find: unrecognized: -mtime
â Ravi
Aug 21 at 9:44
share the distro of linux you are using.
â SivaPrasath
Aug 21 at 9:47
3
It looks like it's busybox built withoutFEATURE_FIND_MTIME
. IsFEATURE_FIND_NEWER
enabled? Doesfind -newer
work? Does yourtest
utility or the[
builtin of yoursh
support-nt
?
â Stéphane Chazelas
Aug 21 at 9:50
1
You can work around this if you can use thosetouch -d
/date +%s
and[ file -nt other-file ]
â Stéphane Chazelas
Aug 21 at 10:08
 |Â
show 5 more comments
up vote
9
down vote
favorite
up vote
9
down vote
favorite
I need to find and delete files older than 1 week in the Development unit. There are limited number utilities available on this unit. -mtime
find
's predicate is not available. How do I check all files which are older than x days in this case?
linux files find date busybox
I need to find and delete files older than 1 week in the Development unit. There are limited number utilities available on this unit. -mtime
find
's predicate is not available. How do I check all files which are older than x days in this case?
linux files find date busybox
edited Aug 21 at 12:05
Stéphane Chazelas
282k53518851
282k53518851
asked Aug 21 at 9:27
Ravi
319213
319213
2
It is unclear what you mean with "mtime
is not available". It's not a utility whose name I recognise.
â Kusalananda
Aug 21 at 9:35
/path/to/my/folder$ find -type f -mtime +7 delete find: unrecognized: -mtime
â Ravi
Aug 21 at 9:44
share the distro of linux you are using.
â SivaPrasath
Aug 21 at 9:47
3
It looks like it's busybox built withoutFEATURE_FIND_MTIME
. IsFEATURE_FIND_NEWER
enabled? Doesfind -newer
work? Does yourtest
utility or the[
builtin of yoursh
support-nt
?
â Stéphane Chazelas
Aug 21 at 9:50
1
You can work around this if you can use thosetouch -d
/date +%s
and[ file -nt other-file ]
â Stéphane Chazelas
Aug 21 at 10:08
 |Â
show 5 more comments
2
It is unclear what you mean with "mtime
is not available". It's not a utility whose name I recognise.
â Kusalananda
Aug 21 at 9:35
/path/to/my/folder$ find -type f -mtime +7 delete find: unrecognized: -mtime
â Ravi
Aug 21 at 9:44
share the distro of linux you are using.
â SivaPrasath
Aug 21 at 9:47
3
It looks like it's busybox built withoutFEATURE_FIND_MTIME
. IsFEATURE_FIND_NEWER
enabled? Doesfind -newer
work? Does yourtest
utility or the[
builtin of yoursh
support-nt
?
â Stéphane Chazelas
Aug 21 at 9:50
1
You can work around this if you can use thosetouch -d
/date +%s
and[ file -nt other-file ]
â Stéphane Chazelas
Aug 21 at 10:08
2
2
It is unclear what you mean with "
mtime
is not available". It's not a utility whose name I recognise.â Kusalananda
Aug 21 at 9:35
It is unclear what you mean with "
mtime
is not available". It's not a utility whose name I recognise.â Kusalananda
Aug 21 at 9:35
/path/to/my/folder$ find -type f -mtime +7 delete find: unrecognized: -mtime
â Ravi
Aug 21 at 9:44
/path/to/my/folder$ find -type f -mtime +7 delete find: unrecognized: -mtime
â Ravi
Aug 21 at 9:44
share the distro of linux you are using.
â SivaPrasath
Aug 21 at 9:47
share the distro of linux you are using.
â SivaPrasath
Aug 21 at 9:47
3
3
It looks like it's busybox built without
FEATURE_FIND_MTIME
. Is FEATURE_FIND_NEWER
enabled? Does find -newer
work? Does your test
utility or the [
builtin of your sh
support -nt
?â Stéphane Chazelas
Aug 21 at 9:50
It looks like it's busybox built without
FEATURE_FIND_MTIME
. Is FEATURE_FIND_NEWER
enabled? Does find -newer
work? Does your test
utility or the [
builtin of your sh
support -nt
?â Stéphane Chazelas
Aug 21 at 9:50
1
1
You can work around this if you can use those
touch -d
/date +%s
and [ file -nt other-file ]
â Stéphane Chazelas
Aug 21 at 10:08
You can work around this if you can use those
touch -d
/date +%s
and [ file -nt other-file ]
â Stéphane Chazelas
Aug 21 at 10:08
 |Â
show 5 more comments
2 Answers
2
active
oldest
votes
up vote
10
down vote
accepted
-mtime
is a standard predicate of find
(contrary to -delete
) but it looks like you have a stripped down version of busybox
, where the FEATURE_FIND_MTIME
feature has been disabled at build time.
If you can rebuild busybox with it enabled, you should be able to do:
find . -mtime +6 -type f -exec rm -f +
Or if FEATURE_FIND_DELETE
is also enabled:
find . -mtime +6 -type f -delete
If not, other options could be to use find -newer
(assuming FEATURE_FIND_NEWER
is enabled) on a file that is set to have a one week old modification time.
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -newer ../ref -exec rm -f +
Or if -newer
is not available but sh
's [
supports -nt
:
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -exec sh -c '
for f do
[ "$f" -nt ../ref ] || printf "%s" "$f"
done' sh + |
xargs -0 rm -f
Yes, busybox was a lighter version here. After re-build,find . -mtime +6 -type f -exec rm ;
worked for me
â Ravi
Aug 21 at 11:42
add a comment |Â
up vote
2
down vote
From man find
:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least
two days ago.
-ctime n
File's status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times.
Depending on the use cases of the files you want to delete, these are your only other options for find
. Why is mtime
not available? What filesystem are you using? Did you explore any other options?
Asking more questions of the OP should be done as clarifying comments, not answers.
â Jeff Schaller
Aug 21 at 11:59
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
-mtime
is a standard predicate of find
(contrary to -delete
) but it looks like you have a stripped down version of busybox
, where the FEATURE_FIND_MTIME
feature has been disabled at build time.
If you can rebuild busybox with it enabled, you should be able to do:
find . -mtime +6 -type f -exec rm -f +
Or if FEATURE_FIND_DELETE
is also enabled:
find . -mtime +6 -type f -delete
If not, other options could be to use find -newer
(assuming FEATURE_FIND_NEWER
is enabled) on a file that is set to have a one week old modification time.
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -newer ../ref -exec rm -f +
Or if -newer
is not available but sh
's [
supports -nt
:
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -exec sh -c '
for f do
[ "$f" -nt ../ref ] || printf "%s" "$f"
done' sh + |
xargs -0 rm -f
Yes, busybox was a lighter version here. After re-build,find . -mtime +6 -type f -exec rm ;
worked for me
â Ravi
Aug 21 at 11:42
add a comment |Â
up vote
10
down vote
accepted
-mtime
is a standard predicate of find
(contrary to -delete
) but it looks like you have a stripped down version of busybox
, where the FEATURE_FIND_MTIME
feature has been disabled at build time.
If you can rebuild busybox with it enabled, you should be able to do:
find . -mtime +6 -type f -exec rm -f +
Or if FEATURE_FIND_DELETE
is also enabled:
find . -mtime +6 -type f -delete
If not, other options could be to use find -newer
(assuming FEATURE_FIND_NEWER
is enabled) on a file that is set to have a one week old modification time.
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -newer ../ref -exec rm -f +
Or if -newer
is not available but sh
's [
supports -nt
:
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -exec sh -c '
for f do
[ "$f" -nt ../ref ] || printf "%s" "$f"
done' sh + |
xargs -0 rm -f
Yes, busybox was a lighter version here. After re-build,find . -mtime +6 -type f -exec rm ;
worked for me
â Ravi
Aug 21 at 11:42
add a comment |Â
up vote
10
down vote
accepted
up vote
10
down vote
accepted
-mtime
is a standard predicate of find
(contrary to -delete
) but it looks like you have a stripped down version of busybox
, where the FEATURE_FIND_MTIME
feature has been disabled at build time.
If you can rebuild busybox with it enabled, you should be able to do:
find . -mtime +6 -type f -exec rm -f +
Or if FEATURE_FIND_DELETE
is also enabled:
find . -mtime +6 -type f -delete
If not, other options could be to use find -newer
(assuming FEATURE_FIND_NEWER
is enabled) on a file that is set to have a one week old modification time.
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -newer ../ref -exec rm -f +
Or if -newer
is not available but sh
's [
supports -nt
:
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -exec sh -c '
for f do
[ "$f" -nt ../ref ] || printf "%s" "$f"
done' sh + |
xargs -0 rm -f
-mtime
is a standard predicate of find
(contrary to -delete
) but it looks like you have a stripped down version of busybox
, where the FEATURE_FIND_MTIME
feature has been disabled at build time.
If you can rebuild busybox with it enabled, you should be able to do:
find . -mtime +6 -type f -exec rm -f +
Or if FEATURE_FIND_DELETE
is also enabled:
find . -mtime +6 -type f -delete
If not, other options could be to use find -newer
(assuming FEATURE_FIND_NEWER
is enabled) on a file that is set to have a one week old modification time.
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -newer ../ref -exec rm -f +
Or if -newer
is not available but sh
's [
supports -nt
:
touch -d "@$(($(date +%s) - 7 * 86400))" ../ref &&
find . ! -type f -exec sh -c '
for f do
[ "$f" -nt ../ref ] || printf "%s" "$f"
done' sh + |
xargs -0 rm -f
edited Aug 21 at 16:50
answered Aug 21 at 11:38
Stéphane Chazelas
282k53518851
282k53518851
Yes, busybox was a lighter version here. After re-build,find . -mtime +6 -type f -exec rm ;
worked for me
â Ravi
Aug 21 at 11:42
add a comment |Â
Yes, busybox was a lighter version here. After re-build,find . -mtime +6 -type f -exec rm ;
worked for me
â Ravi
Aug 21 at 11:42
Yes, busybox was a lighter version here. After re-build,
find . -mtime +6 -type f -exec rm ;
worked for meâ Ravi
Aug 21 at 11:42
Yes, busybox was a lighter version here. After re-build,
find . -mtime +6 -type f -exec rm ;
worked for meâ Ravi
Aug 21 at 11:42
add a comment |Â
up vote
2
down vote
From man find
:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least
two days ago.
-ctime n
File's status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times.
Depending on the use cases of the files you want to delete, these are your only other options for find
. Why is mtime
not available? What filesystem are you using? Did you explore any other options?
Asking more questions of the OP should be done as clarifying comments, not answers.
â Jeff Schaller
Aug 21 at 11:59
add a comment |Â
up vote
2
down vote
From man find
:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least
two days ago.
-ctime n
File's status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times.
Depending on the use cases of the files you want to delete, these are your only other options for find
. Why is mtime
not available? What filesystem are you using? Did you explore any other options?
Asking more questions of the OP should be done as clarifying comments, not answers.
â Jeff Schaller
Aug 21 at 11:59
add a comment |Â
up vote
2
down vote
up vote
2
down vote
From man find
:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least
two days ago.
-ctime n
File's status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times.
Depending on the use cases of the files you want to delete, these are your only other options for find
. Why is mtime
not available? What filesystem are you using? Did you explore any other options?
From man find
:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least
two days ago.
-ctime n
File's status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times.
Depending on the use cases of the files you want to delete, these are your only other options for find
. Why is mtime
not available? What filesystem are you using? Did you explore any other options?
answered Aug 21 at 9:35
OneK
1013
1013
Asking more questions of the OP should be done as clarifying comments, not answers.
â Jeff Schaller
Aug 21 at 11:59
add a comment |Â
Asking more questions of the OP should be done as clarifying comments, not answers.
â Jeff Schaller
Aug 21 at 11:59
Asking more questions of the OP should be done as clarifying comments, not answers.
â Jeff Schaller
Aug 21 at 11:59
Asking more questions of the OP should be done as clarifying comments, not answers.
â Jeff Schaller
Aug 21 at 11:59
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f463813%2ffinding-files-older-than-x-days-on-a-system-with-a-stripped-down-busybox%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
It is unclear what you mean with "
mtime
is not available". It's not a utility whose name I recognise.â Kusalananda
Aug 21 at 9:35
/path/to/my/folder$ find -type f -mtime +7 delete find: unrecognized: -mtime
â Ravi
Aug 21 at 9:44
share the distro of linux you are using.
â SivaPrasath
Aug 21 at 9:47
3
It looks like it's busybox built without
FEATURE_FIND_MTIME
. IsFEATURE_FIND_NEWER
enabled? Doesfind -newer
work? Does yourtest
utility or the[
builtin of yoursh
support-nt
?â Stéphane Chazelas
Aug 21 at 9:50
1
You can work around this if you can use those
touch -d
/date +%s
and[ file -nt other-file ]
â Stéphane Chazelas
Aug 21 at 10:08