mtime VS atime VS ctime

hi, in trying to maintain your directories, one needs to do some housekeeping like removing old files. the tool "find" comes in handy. but how would you decide which option to use when it comes to, say, deleting files that are older than 5 days?

mtime - last modified
atime - last accessed
ctime - last changed

ctime is quite easy to understand. but mtime and atime? how do you differentiate?

i normally use mtime. would i be missing something if i don't use atime?

It depends on how you consider a file active.

If a file is seldom changed, but often read, mtime and ctime would show the file as old, even if it's not.
If a file is only temporary (eg. spooled from a DB), and only used once, mtime would be a good bet.
I can't think of a good example for ctime, as it's only changed when the inode associated with the file changes, eg. changes in file size or name.

hmmm, there are Oracle files that gets created daily but need only for rollbacks. otherwise they accumulate like gremlins. i just need to keep 5 days worth.

i guess my use of mtime is justifiable then.

If you mean the archive files, those are needed for recovery since the last full backup. But usually rman should clean them out too.

1 Like

ctime == last time the inode changed - ie., chmod, chown, etc.
atime == last time the file was read
mtime == last time the file was written, or open append and closed without writing.