brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: find -mtime +7 means at least eight days old, because fractions are dropped

Find
~/tips/tip-find-mtime-rounding-days

find /backup -type f -mtime +7 -print

Explains how find rounds ages in days and how to get a finer cut-off in minutes.

The day tests of find round in a way that surprises people, and a cleanup job can remove more or less than intended.

find /backup -type f -mtime +7 -print
find /backup -type f -mmin +10080 -print

GNU find ignores the fractional part of the age in days. A file that is 7.9 days old counts as 7 days, so -mtime +7 only matches files that are 8 days or older. -mtime 7 matches a single day, and -mtime -7 means less than 7 whole days. If you want a finer cut-off, use minutes: 7 days are 10080 minutes. Print the list before you add -delete.

Further reading: find manual page

More Find tips find / -maxdepth 1 -fstype proc find /backup -name '*.gz' ! -exec gzip -t {} \; -print 2>/dev/null find /srv/downloads -type f -size +100M -size -1G -exec ls -lh {} + find /srv/data -depth -print find /srv -xdev -samefile /srv/downloads/movie.mkv All Find tips (46) All topics

Link