As far as I recall, relatime
updates the access time every 24 h or if the old atime was earlier than or equal to mtime. That would let you know if the program has been unused for a full day; or, if you don't care to wait, run touch programfile
and then see if the atime has changed later.
Plain touch
would set atime == mtime, but atime gets updated if it's <= mtime, so that's ok. You could also do something like touch -a -d 1999-12-31
instead to change atime without modifying mtime.
Like so:
$ cp /bin/ls .
$ touch ./ls
$ stat ./ls
...
Access: 2022-01-07 13:07:16.640132600 +0200
Modify: 2022-01-07 13:07:16.640132600 +0200
Change: 2022-01-07 13:07:16.640132600 +0200
Birth: -
$ ./ls > /dev/null
$ stat ./ls
...
Access: 2022-01-07 13:07:57.175525517 +0200
Modify: 2022-01-07 13:07:16.640132600 +0200
Change: 2022-01-07 13:07:16.640132600 +0200
Birth: -
The access timestamp was updated when the program was run.
Of course, atime would also change if the file is just read. It's probably not that common for binary files to be read just like that, but e.g. a backup tool could do just that. That would make atime useless for this.
But if atime doesn't change, then the file has been neither read nor executed, so it can be used to prove the negative case.
acct
)? – Stephen Kitt Jan 07 '22 at 05:38relatime
update the access time every 24 h or if the old atime was earlier than mtime? That would let you know if the program has been unused for a full day, or you could justtouch programfile
and then check if the atime gets updated after that. That is of course assuming there's nothing else to read the file. – ilkkachu Jan 07 '22 at 06:45touch
ing the file to update mtime. running the program should update atime if it was <= mtime. – ilkkachu Jan 07 '22 at 06:48chmod a-x
and check for errors :P – ilkkachu Jan 07 '22 at 06:49