For those who might be questioning, mtime
or short for modified timestamp, is a Linux file timestamp which usually goes hand in hand with the find
command in the most common scenarios, including finding and removing files or backups older than n days. At first, it seems pretty straightforward to use, but there are few gotchas when trying to find files before, after and in between the 24h period of time.
Prerequisites
- Shell environment
Solution
Get files modified in the last 24h:
find / -mtime 0
or,
find / -mtime -1
Get files modified more than 24h:
find / -mtime +0
Get files modified between 24h and 48h:
find / -mtime 1
Get files modified more than 48h:
find / -mtime +1
Conclusion
As always, hope this was clear enough. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.