Linux command
fadvise 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Suggest
fadvise -a willneed [path/to/file]
Suggest dropping
fadvise [path/to/file]
Apply advice
fadvise -a sequential -o [offset] -l [length] [path/to/file]
Apply advice
fadvise -a dontneed -d [fd]
Example
fadvise -h
说明
fadvise is a simple wrapper around the posix_fadvise(2) system call. It provides the kernel with a hint about how an application intends to access a file so that the kernel can optimize I/O behavior and page cache usage. Useful for preloading files before heavy read workloads, or for dropping pages after a one-shot sequential read.
参数
- -a, --advice _advice_
- Caching advice. One of: normal, sequential, random, noreuse, willneed, dontneed. Defaults to dontneed.
- -d, --fd _fd_
- Apply advice to the given open file descriptor instead of a path.
- -o, --offset _offset_
- Byte offset to start from (default 0).
- -l, --length _length_
- Number of bytes to apply advice to (0 = entire file, default).
- -h, --help
- Display help.
- -V, --version
- Display version.
FAQ
What is the fadvise command used for?
fadvise is a simple wrapper around the posix_fadvise(2) system call. It provides the kernel with a hint about how an application intends to access a file so that the kernel can optimize I/O behavior and page cache usage. Useful for preloading files before heavy read workloads, or for dropping pages after a one-shot sequential read.
How do I run a basic fadvise example?
Run `fadvise -a willneed [path/to/file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a, --advice _advice_ do in fadvise?
Caching advice. One of: normal, sequential, random, noreuse, willneed, dontneed. Defaults to dontneed.