1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified by Michael Haardt <michael@moria.de>
6 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
7 .\" Modified 1995-06-10 by Andries Brouwer <aeb@cwi.nl>
8 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
9 .\" Modified 2004-10-10 by Andries Brouwer <aeb@cwi.nl>
11 .TH utime 2 (date) "Linux man-pages (unreleased)"
13 utime, utimes \- change file last access and modification times
16 .RI ( libc ", " \-lc )
21 .BI "int utime(const char *" filename ,
22 .BI " const struct utimbuf *_Nullable " times );
24 .B #include <sys/time.h>
26 .BI "int utimes(const char *" filename ,
27 .BI " const struct timeval " times "[_Nullable 2]);"
31 modern applications may prefer to use the interfaces described in
37 changes the access and modification times of the inode specified by
40 .IR actime " and " modtime
44 The status change time (ctime) will be set to the current time, even if the
45 other time stamps don't actually change.
49 is NULL, then the access and modification times of the file are set
52 Changing timestamps is permitted when: either
53 the process has appropriate privileges,
54 or the effective user ID equals the user ID
57 is NULL and the process has write permission for the file.
66 time_t actime; /* access time */
67 time_t modtime; /* modification time */
75 allows specification of timestamps with a resolution of 1 second.
82 argument refers to an array rather than a structure.
83 The elements of this array are
85 structures, which allow a precision of 1 microsecond for specifying timestamps.
93 long tv_sec; /* seconds */
94 long tv_usec; /* microseconds */
100 specifies the new access time, and
102 specifies the new modification time.
105 is NULL, then analogously to
107 the access and modification times of the file are
108 set to the current time.
110 On success, zero is returned.
111 On error, \-1 is returned, and
113 is set to indicate the error.
117 Search permission is denied for one of the directories in
121 .BR path_resolution (7)).
126 the caller's effective user ID does not match the owner of the file,
127 the caller does not have write access to the file,
128 and the caller is not privileged
129 (Linux: does not have either the
142 the caller's effective UID does not match the owner of the file,
143 and the caller is not privileged
144 (Linux: does not have the
150 resides on a read-only filesystem.
157 POSIX.1-2008 marks it as obsolete.
160 4.3BSD, POSIX.1-2001.
162 Linux does not allow changing the timestamps on an immutable file,
163 or setting the timestamps to something other than the current time
164 on an append-only file.
166 .\" In libc4 and libc5,
168 .\" is just a wrapper for
170 .\" and hence does not allow a subsecond resolution.