'How can I change file's last access?
How can I change the file's last access by utime and mktime in linux ?
(for example, to update the file's last access to:11 (seconds) : 11 (minutes) : 11 (hour) : 11 (day) : 11 (month) : 1500 (year) )
I know that I can do it by touch command, but I try to do it by these system calls.. ideas?
Solution 1:[1]
you use utimensat : utimensat
utimensat() and futimens() update the timestamps of a file with nanosecond precision. This contrasts with the historical utime(2) and utimes(2), which permit only second and microsecond precision, respectively, when setting file timestamps.
With utimensat() the file is specified via the pathname given in
pathname. With futimens() the file whose timestamps are to be
updated is specified via an open file descriptor, fd.
For both calls, the new file timestamps are specified in the
array times: times[0] specifies the new "last access time"
(atime); times[1] specifies the new "last modification time"
(mtime). Each of the elements of times specifies a time as the
number of seconds and nanoseconds since the Epoch, 1970-01-01
00:00:00 +0000 (UTC). This information is conveyed in a
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
