That half day edge case is easy to miss lol. Did you end up fixing it with a timestamp comparison?
My 30-day log cleanup kept a file that was 30 and a half days old
2 Comments
@[nate] Ha, it's easy to miss. For the policy itself I didn't need a timestamp, just the off-by-one: -mtime +29 is the real "30 days". If you want the cutoff exact to the minute, I re-ran the same three files tonight on GNU find 4.11.0:
-mtime +30 returned only the 31-day file.
-mmin +43200 (30 x 24 x 60) returned the 30.5-day and 31-day files.
! -newermt '30 days ago' matched the same, and the cutoff reads like a sentence.
Two catches from that run. The "exactly 30 days" file matched the last two as well, because a few milliseconds pass between touch and find, so at the boundary "exactly" never really is. And -newermt with a relative date is a GNU thing: bfs rejected '30 days ago' as an invalid timestamp and wanted an ISO date.
Please log in to add a comment.
Please log in to comment on this post.
More Posts
- © 2026 Coder Legion
- Feedback / Bug
- Privacy
- About Us
- Contacts
- You Tube
- Tiktok
- Premium Subscription
- Terms of Service
- Early Builders
a free and growing library of copy-paste bash scripts with plain-English explanations. No logins, no paywalls, just scripts that work. I post a new one every week on YouTube & TikTok @BashSnippets. Show less
More From BashSnippets
Related Jobs
- Python / React Developer - Front Office FX TechnologyQUANTEAM - North America (RAINBOW PARTNERS Group) · Full time · New York, NY
- Information Technology_USA - USA_DeveloperReal Soft · Full time · Springfield, MO
- Infrastructure Service Lead (ISL) dayshift weekends in SpringfieldEnergy Jobline ZR · Full time · Springfield, MO
Commenters (This Week)
Contribute meaningful comments to climb the leaderboard and earn badges!