How long file was opened

Hello

I’m curious: is there a way in linux to know for how long a particular file was opened?

Let’s say I’m writing something in KWrite and the file is file.txt
I’d like to know for how long it was opened in Kwrite (how long I was editing it).
Or I’m doing subtitles and the file is file.srt and I want to know how much time I spent on it.

Is it possible to know?

If the application you are using has logging, that may tell you, and
that’s likely the best way to know anything like that for sure. An
application is probably not likely to hold open an original file (vs. a
temporary file, which may be similarly-named and be open) for long periods
of time because that’s kind of silly architecturally, and in any case you
will not see anything about that from the file itself, but may from
something like the /proc filesystem, auditing systems, or similar.
Auditing may be your best, application-agnostic, bet, as you could see a
file-open event, and later on a file-write event after changes are made
(assuming they are made), but even then you rely on the application
keeping something open long-term, which isn’t a safe assumption for most
applications.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

LibreOffice records the total editing time in File>Properties. So if you look at this when you start editing and look again just before you close, you can work it out. If you are writing, say, an article, the total editing time will tell you how long it took you to get to the final version.

Thanks.

I know about LibreOffice. I’m rather interested in other files. Right now I’d like to know my work hours in Gnome Subtitles.
I was inspired with this feature in Dolphin, where you can right-click on a file and view Properties and there you will find information about the file - Created, Modified, Accessed.
So I thought it should be simple to get info on time spent on a file.

To ab - where shall I search for logs (Gnome Subtitles)?

If the application you are using has logging, that may tell you, and
that’s likely the best way to know anything like that for sure. An
application is probably not likely to hold open an original file (vs. a
temporary file, which may be similarly-named and be open) for long periods
of time because that’s kind of silly architecturally, and in any case you
will not see anything about that from the file itself, but may from
something like the /proc filesystem, auditing systems, or similar.
Auditing may be your best, application-agnostic, bet, as you could see a
file-open event, and later on a file-write event after changes are made
(assuming they are made), but even then you rely on the application
keeping something open long-term, which isn’t a safe assumption for most
applications.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…