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 2021-03-22 "Linux" "Linux Programmer's Manual"
33 utime, utimes \- change file last access and modification times
38 .BI "int utime(const char *" filename ", const struct utimbuf *" times );
40 .B #include <sys/time.h>
42 .BI "int utimes(const char *" filename ", const struct timeval " times [2]);
46 modern applications may prefer to use the interfaces described in
52 changes the access and modification times of the inode specified by
55 .IR actime " and " modtime
62 is NULL, then the access and modification times of the file are set
65 Changing timestamps is permitted when: either
66 the process has appropriate privileges,
67 or the effective user ID equals the user ID
70 is NULL and the process has write permission for the file.
79 time_t actime; /* access time */
80 time_t modtime; /* modification time */
88 allows specification of timestamps with a resolution of 1 second.
95 argument refers to an array rather than a structure.
96 The elements of this array are
98 structures, which allow a precision of 1 microsecond for specifying timestamps.
106 long tv_sec; /* seconds */
107 long tv_usec; /* microseconds */
113 specifies the new access time, and
115 specifies the new modification time.
118 is NULL, then analogously to
120 the access and modification times of the file are
121 set to the current time.
123 On success, zero is returned.
124 On error, \-1 is returned, and
126 is set to indicate the error.
130 Search permission is denied for one of the directories in
134 .BR path_resolution (7)).
139 the caller's effective user ID does not match the owner of the file,
140 the caller does not have write access to the file,
141 and the caller is not privileged
142 (Linux: does not have either the
155 the caller's effective UID does not match the owner of the file,
156 and the caller is not privileged
157 (Linux: does not have the
163 resides on a read-only filesystem.
172 4.3BSD, POSIX.1-2001.
174 Linux does not allow changing the timestamps on an immutable file,
175 or setting the timestamps to something other than the current time
176 on an append-only file.
178 .\" In libc4 and libc5,
180 .\" is just a wrapper for
182 .\" and hence does not allow a subsecond resolution.