1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" 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 2008-08-06 "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]);
50 changes the access and modification times of the inode specified by
53 .IR actime " and " modtime
60 is NULL, then the access and modification times of the file are set
63 Changing timestamps is permitted when: either
64 the process has appropriate privileges,
65 or the effective user ID equals the user ID
68 is NULL and the process has write permission for the file.
77 time_t actime; /* access time */
78 time_t modtime; /* modification time */
86 allows specification of timestamps with a resolution of 1 second.
93 argument refers to an array rather than a structure.
94 The elements of this array are
96 structures, which allow a precision of 1 microsecond for specifying timestamps.
104 long tv_sec; /* seconds */
105 long tv_usec; /* microseconds */
111 specifies the new access time, and
113 specifies the new modification time.
116 is NULL, then analogously to
118 the access and modification times of the file are
119 set to the current time.
121 On success, zero is returned.
122 On error, \-1 is returned, and
124 is set appropriately.
128 Search permission is denied for one of the directories in
132 .BR path_resolution (7)).
137 the caller's effective user ID does not match the owner of the file,
138 the caller does not have write access to the file,
139 and the caller is not privileged
140 (Linux: does not have either the
153 the caller's effective UID does not match the owner of the file,
154 and the caller is not privileged
155 (Linux: does not have the
161 resides on a read-only file system.
170 4.3BSD, POSIX.1-2001.
172 Linux does not allow changing the timestamps on an immutable file,
173 or setting the timestamps to something other than the current time
174 on an append-only file.
178 is just a wrapper for
180 and hence does not allow a subsecond resolution.