1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1995-06-10 by Andries Brouwer <aeb@cwi.nl>
28 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Modified 2004-10-10 by Andries Brouwer <aeb@cwi.nl>
31 .TH UTIME 2 2017-09-15 "Linux" "Linux Programmer's Manual"
33 utime, utimes \- change file last access and modification times
36 .B #include <sys/types.h>
39 .BI "int utime(const char *" filename ", const struct utimbuf *" times );
41 .B #include <sys/time.h>
43 .BI "int utimes(const char *" filename ", const struct timeval " times [2]);
47 modern applications may prefer to use the interfaces described in
53 changes the access and modification times of the inode specified by
56 .IR actime " and " modtime
63 is NULL, then the access and modification times of the file are set
66 Changing timestamps is permitted when: either
67 the process has appropriate privileges,
68 or the effective user ID equals the user ID
71 is NULL and the process has write permission for the file.
80 time_t actime; /* access time */
81 time_t modtime; /* modification time */
89 allows specification of timestamps with a resolution of 1 second.
96 argument refers to an array rather than a structure.
97 The elements of this array are
99 structures, which allow a precision of 1 microsecond for specifying timestamps.
107 long tv_sec; /* seconds */
108 long tv_usec; /* microseconds */
114 specifies the new access time, and
116 specifies the new modification time.
119 is NULL, then analogously to
121 the access and modification times of the file are
122 set to the current time.
124 On success, zero is returned.
125 On error, \-1 is returned, and
127 is set appropriately.
131 Search permission is denied for one of the directories in
135 .BR path_resolution (7)).
140 the caller's effective user ID does not match the owner of the file,
141 the caller does not have write access to the file,
142 and the caller is not privileged
143 (Linux: does not have either the
156 the caller's effective UID does not match the owner of the file,
157 and the caller is not privileged
158 (Linux: does not have the
164 resides on a read-only filesystem.
173 4.3BSD, POSIX.1-2001.
175 Linux does not allow changing the timestamps on an immutable file,
176 or setting the timestamps to something other than the current time
177 on an append-only file.
179 .\" In libc4 and libc5,
181 .\" is just a wrapper for
183 .\" and hence does not allow a subsecond resolution.