Method: Unix::Exec#modified_at

Defined in:
lib/beaker/host/unix/exec.rb

#modified_at(file, timestamp = nil) ⇒ Object

Update ModifiedDate on a file

Parameters:

  • file (String)

    Path to the file

  • timestamp (String) (defaults to: nil)

    Timestamp to set



126
127
128
129
130
131
# File 'lib/beaker/host/unix/exec.rb', line 126

def modified_at(file, timestamp = nil)
  require 'date'
  time = timestamp ? DateTime.parse("#{timestamp}") : DateTime.now
  timestamp = time.strftime('%Y%m%d%H%M')
  execute("/bin/touch -mt #{timestamp} #{file}")
end