听老歌 发表于 2012-02-03 18:43

File Descriptors per Process .

File Descriptors per Process .






A file descriptor is a handle created by a process when a file is opened. There is a limit to the amount of file descriptors per process. In order to check the default limit of the system, you can use command:

1.ulimit -a # all limitations
2.ulimit -Sn # soft limit
3.ulimit -Hn # hard limit
If the file descriptor limit is exceeded for a process, you may see the error Too Many Open Files.

And if you want to change the limit per process temporarily, you can:

1.ulimit -n <desired_#> # both
2.ulimit -Sn <desired_#> # soft limit
3.ulimit -Hn <desired_#> # hard limit
To check the open files of a process, you can use command pfiles <PID>.

To check the run time limit of each process in Solaris, you can plimit <PID>(it seems this command is not supported in Linux). If you have the root permission and you want to change the limit of an process without killing or restarting the process, you can plimit -n <desired_#>.

It was said that it may be dangerous to set the soft limit higher than 256 or hard limit greater than 1024 due to limitations with the stdio library.If programs require more file descriptors, they should use setrlimit directly.

-------------
References:

1.File descriptors
2.Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)
3.Linux / UNIX: List Open Files for Process
4.Princeton University Enterprise Servers and Storage, File Descriptors
5.plimit

冰释一片天 发表于 2012-02-03 18:44

谢谢分享
页: [1]
查看完整版本: File Descriptors per Process .