Linux 什么是 .pid 文件,它包含什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8296170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is a .pid file and what does it contain?
提问by ifixthat
I recently come across a file with the extension .pid and explored inside it but didn't find much. The documentation says:
我最近遇到了一个扩展名为 .pid 的文件,并在其中进行了探索,但没有找到太多内容。文档说:
A Pid-File is a file containing the process identification number (pid) that is stored in a well-defined location of the filesystem thus allowing other programs to find out the pid of a running script.
Pid 文件是一个包含进程标识号 (pid) 的文件,该文件存储在文件系统的明确定义的位置,从而允许其他程序找出正在运行的脚本的 pid。
Can anyone shed more light on this, or guide me to details of what's contained in the pid file?
任何人都可以对此进行更多说明,或指导我了解 pid 文件中包含的内容的详细信息吗?
采纳答案by Rafael Steil
The pid files contains the process id (a number) of a given program. For example, Apache HTTPD may write its main process number to a pid file - which is a regular text file, nothing more than that - and later use the information there contained to stop itself. You can also use that information to kill the process yourself, using cat filename.pid | xargs kill
pid 文件包含给定程序的进程 ID(一个数字)。例如,Apache HTTPD 可能会将其主进程号写入一个 pid 文件——它是一个普通的文本文件,仅此而已——然后使用其中包含的信息来停止自身。您还可以使用该信息自己终止进程,使用cat filename.pid | xargs kill
回答by Mithun Sasidharan
To understand pid files, refer this DOC
要了解 pid 文件,请参阅此DOC
Some times there are certain applications that require additional support of extra plugins and utilities. So it keeps track of these utilities and plugin process running ids using this pid file for reference.
有时,某些应用程序需要额外的插件和实用程序的额外支持。因此,它使用此 pid 文件跟踪这些实用程序和插件进程的运行 ID,以供参考。
That is why whenever you restart an application all necessary plugins and dependant apps must be restarted since the pid file will become stale.
这就是为什么每当您重新启动应用程序时,所有必需的插件和相关应用程序都必须重新启动,因为 pid 文件将变得陈旧。