How do I set -atime
in milliseconds, seconds, or minutes? The default is days:
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.
I'd like to run a cron job, say, hourly to check if files in a particular directory have been accessed within that time frame. Entering time as a decimal doesn't seem to work, i.e.
find . -atime 0.042 -print
But maybe there is a better solution anyway – another command perhaps? Or perhaps this can't be done.. for finding files modified in last x minutes there is -mmin
that allows setting the time in minutes. Perhaps the absence of such option for the access time implies that information is not stored the same way?
I'm using Ubuntu 16.04.
auditd
or one of the filesystem on-inode-change-notify tools might be better options (like, is it okay to not be informed should cron or the cron job not run for some reason?)find
: As was pointed out, there is-amin
... However, maybe-anewer
could work? This uses the creation-time of a reference-file - which you could let your cron-jobtouch
every hour - and then test if some other file has been accessed after the creation of this reference. So your cron-job would first check the directory for files accessed after it lasttouch
ed the reference one hour ago... then it would re-touch
the reference.find directory/ -anewer "ref.file" -type f -print
should work...