Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

fadvise

Advise the kernel about file access patterns via posix_fadvise(2).

Synopsis

fadvise [options] filename
fadvise [options] -d file-descriptor

Operation

Calls posix_fadvise(2) to advise the kernel about expected access patterns for a file. Most commonly used with dontneed to drop a file’s pages from the page cache.

Inputs

  • filename — file to advise on
  • -d fd — file descriptor number (for already-open files in scripts)

Outputs

None (the syscall has no visible output).

Syscalls

SyscallDescription
posix_fadvise(2)Declare access pattern for file data

Advice values

ValueDescription
normalNo special access pattern (default kernel behavior)
sequentialData will be accessed sequentially
randomData will be accessed randomly
noreuseData will be accessed once
willneedData will be needed soon (prefetch)
dontneedData will not be needed soon (drop from cache) — default

Command-line options

OptionDescription
-a, --advice <advice>Advice to apply (default: dontneed)
-o, --offset <bytes>Beginning offset (default: 0)
-l, --length <bytes>Length of range (default: 0 = to end of file)
-d, --fd <N>Operate on file descriptor N instead of a filename
-h, --helpDisplay help
-V, --versionDisplay version

Exit codes

CodeMeaning
0Success
1Failure