Checking When a File was Last Used : atime « File Directory « Ruby






Checking When a File was Last Used


open("output", "w") { |f| f << "Here's some output.\n" }
stat = File.stat("output")
stat.mtime            
stat.atime            

sleep(2)
open("output", "a") { |f| f << "Here's some more output.\n" }
stat = File.stat("output")
stat.mtime            
stat.atime            


sleep(2)
open("output") { |f| contents = f.read }
stat = File.stat("output")
stat.mtime            
stat.atime            

 








Related examples in the same category

1.Get file last accessed time