futimes(3)

โœจ futimes(3) โ€” change file timestamps โœจ

okay bestie, welcome to the futimes page ๐Ÿ’– โ€” that's futimes and its little sibling lutimes, two tiny glibc cuties that let you mess with a file's access and modification times. They live in the Standard C library, a.k.a. libc (link with -lc), so you already have them, no cap ๐ŸŒธ


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

#include <sys/time.h>

int futimes(int fd, const struct timeval tv[2]);
int lutimes(const char *path, const struct timeval tv[2]);

๐ŸŽ€ Feature Test Macro Requirements for glibc ๐ŸŽ€

(peep feature_test_macros(7) if you're confused, queen)

futimes(), lutimes():

  • Since glibc 2.19:
    • _DEFAULT_SOURCE
  • glibc 2.19 and earlier:
    • _BSD_SOURCE
fr fr, define the right macro before you include anything, or these functions will ghost you ๐Ÿ™ˆ

๐Ÿ’… DESCRIPTION ๐Ÿ’…

futimes() changes the access and modification times of a file exactly the same way utimes(2) does โ€” the only glow-up is that you tell it which file via a file descriptor, fd, instead of a pathname. it's giving "I already have the fd open, why would I re-open by path" energy ๐Ÿ˜Œ

lutimes() also changes access and modification times just like utimes(2), but with one iconic twist: if path points at a symbolic link, the link does not get dereferenced. instead, it changes the timestamps of the symbolic link itself ๐Ÿฆ‹ (yes, links have timestamps too, main character behavior honestly)


โญ RETURN VALUE โญ

  • On success: 0 is returned ๐ŸŽ‰
  • On error: -1 is returned, and errno is set to tell you what went wrong ๐Ÿ˜ญ

๐Ÿ”ฅ ERRORS ๐Ÿ”ฅ

Errors are as for utimes(2), plus these extra ones for futimes():

  • EBADF โ€” fd is not a valid file descriptor. bestie that fd is not real ๐Ÿ’€
  • ENOSYS โ€” the /proc filesystem could not be accessed.

And this additional error can happen for lutimes():

  • ENOSYS โ€” the kernel does not support this call; Linux 2.6.22 or later is required. old kernel? no lutimes for you ๐Ÿซถ

๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

for the whole explanation of what these terms mean, go read attributes(7) โ€” iykyk

  • Interface: futimes(), lutimes()
    • Attribute: Thread safety
    • Value: MT-Safe

so yes, they're thread-safe. slay ๐ŸŽ€


๐ŸŒŸ STANDARDS ๐ŸŒŸ

Linux, BSD.


๐Ÿงš HISTORY ๐Ÿงš

  • futimes() โ€” glibc 2.3.
  • lutimes() โ€” glibc 2.6.

glow-up timeline, honestly ๐Ÿ“ˆ


๐Ÿ’œ NOTES ๐Ÿ’œ

lutimes() is implemented using the utimensat(2) system call. that's the whole tea โ˜•


๐ŸŒธ SEE ALSO ๐ŸŒธ

utime(2), utimensat(2), symlink(7)


lowkey reminder: futimes() takes an fd, lutimes() takes a path and doesn't follow symlinks. don't mix them up bestie ๐Ÿ˜ญ

and that's the page, periodt ๐Ÿ’… this was Linux man-pages 6.20, dated 2026-02-08 โ€” mwah, go change some timestamps responsibly ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms