91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

pidfile 與 logfile的不同

發布時間:2020-09-20 17:03:42 來源:網絡 閱讀:1202 作者:落寞三少 欄目:系統運維

原文答案:http://unix.stackexchange.com/questions/12815/what-are-pid-and-lock-files-for

大意翻譯如下:

pidfile 是用戶程序正在開始運行期間,將進程ID寫進pidfile文件,主要目的有三個:

    1.為其他程序或操作系統標識本程序正在運行,或至少啟動成功了。

    2.如果計劃要用kill命令終止進行,它允許一個可寫腳本非常容易地檢測程序運行狀態。

    3.有pidfile后,可以用非常少的代價去獲取前一個運行實例因何沒有退出成功


僅僅存在pidfile并不能保證進程id是否正在運行,這個方法不是100%簡單,但對大多數程序來說是足夠好的,檢測進程id是否在進程表這個方式并不能跨平臺使用,除非使用 ps工具。


lockfile 通常用來保證同一程序的兩個實例不能同時運行,使用完后別忘記刪除這個文件

pid files are written by some programs to record their process ID while they are starting. This has multiple purposes:

  • It's a signal to other processes and users of the system that that particular program is running, or at least started successfully.

  • It allows one to write a script really easy to check if it's running and issue a plain kill command if one wants to end it.

  • It's a cheap way for a program to see if a previous running instance of it did not exit successfully.

Mere presence of a pid file doesn't guarantee that that particular process id is running, of course, so this method isn't 100% foolproof but "good enough" in a lot of instances. Checking if a particular PID exists in the process table isn't totally portable across UNIX-like operating systems unless you want to depend on the ps utility, which may not be desirable to call in all instances (and I believe some UNIX-like operating systems implement ps differently anyway).

Lock files are used by programs to ensure two (well-behaved) separate instances of a program, which may be running concurrently on one system, don't access something else at the same time. The idea is before the program accesses its resource, it checks for presence of a lock file, and if the lock file exists, either error out or wait for it to go away. When it doesn't exist, the program wanting to "acquire" the resource creates the file, and then other instances that might come across later will wait for this process to be done with it. Of course, this assumes the program "acquiring" the lock does in fact release it and doesn't forget to delete the lock file.

This works because the filesystem under all UNIX-like operating systems enforces serialization, which means only one change to the filesystem actually happens at any given time. Sort of like locks with databases and such.


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

涿鹿县| 全南县| 福海县| 中方县| 吉水县| 贵德县| 鄯善县| 瓮安县| 北碚区| 德昌县| 理塘县| 遂川县| 抚顺市| 潞城市| 伊金霍洛旗| 屏南县| 深州市| 县级市| 永安市| 广汉市| 阜宁县| 五河县| 苏州市| 海阳市| 乐亭县| 阿鲁科尔沁旗| 大理市| 安西县| 崇义县| 南陵县| 寻乌县| 峡江县| 九台市| 孙吴县| 祁连县| 仪陇县| 通许县| 晋州市| 嘉善县| 彝良县| 会泽县|