find -mtime option on linux listing all files regardless of time?

772 views Asked by At

I'm trying to use the linux find command to show me the files in my current directory that have been modified in the last 24h. To test my command, I piped it to ls as below.

find . -maxdepth 1 -mtime -1 | xargs -I{} ls -lh {}

but this command displays all the files in my directory, some of which were modified last year. What am I missing here? I also tried -atime and -ctime options out of curiosity and got seemingly the same file list.

Many thanks for the advice!

1

There are 1 answers

0
user3817445 On

In my case the issues was caused because I had the wrong system time on my raspberry. This was because systemd-timesyncd.service was no longer running. After:

 sudo systemctl unmask systemd-timesyncd.service
 sudo systemctl enable systemd-timesyncd.service
 sudo reboot

the system time was correct again. Note that the pi needs to be connected to a network for this to work. And also, of course, past wrong file dates don't get fixed by this (duh).