Jump to content

Timestamp when a file was edited?

  • Please log in to reply
3 replies to this topic

#1 AndyG



  • Members
  • Pip
  • 1 posts

Posted 05 March 2020 - 04:22 PM

I'm looking to detect when people have files exclusively locked for more than a week - this is likely a mistake.

Perforce doesn't seem to track the timestamp when a file is edited. fstat only shows the fact a file is being edited, and the headTime refers to the #head time stamp, headModTime refers to the original timestamp when the file was first submitted. Is there any way of detecting *when* a file was edited? I was expecting an ... ... otherTime xxxx filed.

(My current solution is to run a p4 opened -a //depot/... and record in my own database when I first see a file opened *locked*, then I can count the days myself. Perforce should know this time/date however....

#2 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1037 posts

Posted 05 March 2020 - 05:49 PM

You're correct that it's not tracked in the database anywhere (it would be in the db.working table if it were anywhere):  https://www.perforce...ema/#db.working

The modtime (i.e. the client-side timestamp) is apparently stored in there, and you might be able to get it out of "p4 fstat", but that's not necessarily going to correspond to when the file was opened; I'm also not sure when exactly that gets updated (it might only be valid for files that are shelved or in the process of being submitted, which isn't useful for your purposes).

Keeping track of it yourself, similarly to how you're doing, seems like the best workaround.  An alternative to polling "p4 opened -a" might be to tail the journal file (if you have access to it) since that'll let you observe the actual db transactions that open the file (and their exact timestamps) rather than getting the information after the fact; then you just need to store it in your own db.

#3 Matt Janulewicz

Matt Janulewicz

    Advanced Member

  • Members
  • PipPipPip
  • 217 posts
  • LocationSan Francisco, CA

Posted 06 March 2020 - 10:36 PM

Splunk or Graylog might be a good thing to use for the 'store it in your own db' part. It's hard to overstate how useful historical log data can be, especially in an easily searchable tool. Though I have to admit 'grep' and 'awk' have their merits. :)
-Matt Janulewicz
Currently unemployed, looking for work in Boise, ID!

#4 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 182 posts

Posted 07 March 2020 - 01:06 AM

Or just parse the log file from a week ago today.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users