Can some one please tell me how to delete n minutes old files in Solaris? My find does not -mmin option.
Asked
Active
Viewed 4,773 times
2
-
does it have the -ctime option? – Mel Boyce Apr 18 '13 at 11:57
-
Yes. It includes ctime – Maheswari Apr 18 '13 at 11:58
2 Answers
2
If you can calculate the absolute time point (possible using some small script program) you can either use the -newermt YYYYMMDDThhmmss' option, or if that is not supported
toucha file XY with that absolute date and user
-newer XY(or
! -newer XY`).

Anthon
- 79,293
-
You can get a file
reffile
with an absolute time of 10 minutes (600 seconds) ago with e.g.:touch reffile -d "$(python -c 'import datetime; print (datetime.datetime.now() - datetime.timedelta(seconds=600)).replace(microsecond=0).isoformat()')"
(assuming you have python installed) – Anthon Apr 18 '13 at 14:43
1
This is exactly the reason for my posting previously which is pretty much about the tools that your sysadmin (or you) should always make sure is available on your Solaris host. (your problem is solved by GNU find
). If such tools were available by default you wouldn't have had the question in the first place. :-)
You can read more about it here.
So simply use GNU find !!
-
Depending on the version of Solaris being used,
gfind
may be there. Check/opt/sfw/bin
,/usr/sfw/bin
, and/opt/gnu/bin
. – Tim Kennedy May 02 '13 at 14:05 -
1True, but the "here" link in the above text was trying to teach the man to fish rather than to give him a fish. In other words fix the problem with (seemingly) missing GNU tools once and for all .. and not just for
find
. :-) – peterh May 07 '13 at 09:13 -