sync: man page

A lot of people use sync.

Do you know what it does!

Did you know that sometimes sync takes time and isn’t immediately completed.

SYNC(1)                                               SYNC(1)

NAME

       sync - Synchronize cached writes to persistent storage

SYNOPSIS

       sync [OPTION] [FILE]...

DESCRIPTION

       Synchronize cached writes to persistent storage

       If one or more files are specified, sync only them, or their
       containing file systems.

       -d, --data
              sync only file data, no unneeded metadata

       -f, --file-system
              sync the file systems that contain the files

       --help display this help and exit

       --version
              output version information and exit

BUGS

       Persistence guarantees vary per system.  See the system calls below
       for more details.

AUTHOR

       Written by Jim Meyering and Giuseppe Scrivano.

REPORTING BUGS

       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
       Report sync translation bugs to
       <https://translationproject.org/team/>

COPYRIGHT

       Copyright © 2017 Free Software Foundation, Inc.  License GPLv3+: GNU
       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
       This is free software: you are free to change and redistribute it.
       There is NO WARRANTY, to the extent permitted by law.

SEE ALSO

       fdatasync(2), fsync(2), sync(2), syncfs(2)

       Full documentation at: <https://www.gnu.org/software/coreutils/sync>
       or available locally via: info '(coreutils) sync invocation'

COLOPHON

       This page is part of the coreutils (basic file, shell and text
       manipulation utilities) project.  Information about the project can
       be found at ⟨http://www.gnu.org/software/coreutils/⟩.  If you have a
       bug report for this manual page, see
       ⟨http://www.gnu.org/software/coreutils/⟩.  This page was obtained
       from the tarball coreutils-8.29.tar.xz fetched from
       ⟨http://www.gnutls.org/download.html⟩ on 2018-04-30.  If you discover
       any rendering problems in this HTML version of the page, or you
       believe there is a better or more up-to-date source for the page, or
       you have corrections or improvements to the information in this
       COLOPHON (which is not part of the original manual page), send a mail
       to man-pages@man7.org

GNU coreutils 8.29              December 2017                        SYNC(1)

sync(2) – Linux man page

Name

sync, syncfs – commit buffer cache to disk

Synopsis

#include <unistd.h>

void sync(void);

int syncfs(int fd);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

sync():
_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
syncfs():
_GNU_SOURCE

Description

sync() causes all buffered modifications to file metadata and data to be written to the underlying file systems.

syncfs() is like sync(), but synchronizes just the file system containing file referred to by the open file descriptor fd.

Return Value

syncfs() returns 0 on success; on error, it returns -1 and sets errno to indicate the error.

Errors

sync() is always successful.

syncfs() can fail for at least the following reason:

EBADFfd is not a valid file descriptor.

Versions

syncfs() first appeared in Linux 2.6.39; library support was added to glibc in version 2.14.

Conforming To

sync(): SVr4, 4.3BSD, POSIX.1-2001.

syncfs() is Linux-specific.

Notes

Since glibc 2.2.2 the Linux prototype for sync() is as listed above, following the various standards. In libc4, libc5, and glibc up to 2.2.1 it was “int sync(void)”, and sync() always returned 0.

Bugs

According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done. However, since version 1.3.20 Linux does actually wait. (This still does not guarantee data integrity: modern disks have large caches.)

See Also

bdflush(2), fdatasync(2), fsync(2), sync(8), update(8)

Referenced By

apmd(8), clubufflush(8), ctrlaltdel(8), fclose(3), fflush(3), guestfish(1), guestfs(3), nfs(5),reboot(2), sync(1), sync_file_range(2), xfs_quota(8), zshmodules(1)