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 2014-08-19 "Linux" "Linux Programmer's Manual"
33 utime, utimes \- change file last access and modification times
36 .B #include <sys/types.h>
40 .BI "int utime(const char *" filename ", const struct utimbuf *" times );
42 .B #include <sys/time.h>
44 .BI "int utimes(const char *" filename ", const struct timeval " times [2]);
48 modern applications may prefer to use the interfaces described in
54 changes the access and modification times of the inode specified by
57 .IR actime " and " modtime
64 is NULL, then the access and modification times of the file are set
67 Changing timestamps is permitted when: either
68 the process has appropriate privileges,
69 or the effective user ID equals the user ID
72 is NULL and the process has write permission for the file.
81 time_t actime; /* access time */
82 time_t modtime; /* modification time */
90 allows specification of timestamps with a resolution of 1 second.
97 argument refers to an array rather than a structure.
98 The elements of this array are
100 structures, which allow a precision of 1 microsecond for specifying timestamps.
108 long tv_sec; /* seconds */
109 long tv_usec; /* microseconds */
115 specifies the new access time, and
117 specifies the new modification time.
120 is NULL, then analogously to
122 the access and modification times of the file are
123 set to the current time.
125 On success, zero is returned.
126 On error, \-1 is returned, and
128 is set appropriately.
132 Search permission is denied for one of the directories in
136 .BR path_resolution (7)).
141 the caller's effective user ID does not match the owner of the file,
142 the caller does not have write access to the file,
143 and the caller is not privileged
144 (Linux: does not have either the
157 the caller's effective UID does not match the owner of the file,
158 and the caller is not privileged
159 (Linux: does not have the
165 resides on a read-only filesystem.
174 4.3BSD, POSIX.1-2001.
176 Linux does not allow changing the timestamps on an immutable file,
177 or setting the timestamps to something other than the current time
178 on an append-only file.
180 .\" In libc4 and libc5,
182 .\" is just a wrapper for
184 .\" and hence does not allow a subsecond resolution.