[Linux] 在 /var/log/messages 中尋找 service 啟動/停止的訊息

[Linux] 在 /var/log/messages 中尋找 service 啟動/停止的訊息

在查 Systemctl stop 時,被 service 叫起來的 process 都不見了? 這個問題時,

想要知道 service 曾經什麼時候被叫起來過,

不過從 systemctl status 的輸出,只看得到執行中的 service 是何時起來的:

root@localhost ~ # systemctl status main
main.service - main
Loaded: loaded (/etc/systemd/system/main.service; enabled)
Active: active (running) since Tue 2016-01-05 13:08:54 CST; 7min ago
Main PID: 5701 (main.py)

 

想知道過往記錄的話,怎麼辦呢?

找了一下,原來在 /var/log/messages 是有留一些蛛絲馬跡的,

只要在裡面找 systemd 這個關鍵字,就能看到哪些 service 被叫起來,

和哪些 service 被停掉的訊息,時間也很清楚: 

root@localhost ~ # egrep systemd /var/log/messages
2016-01-05T11:33:20.687237+08:00 localhost systemd: Starting agent...
2016-01-05T11:33:20.688578+08:00 localhost systemd: Started agent.
2016-01-05T11:33:20.689749+08:00 localhost systemd: Starting worker...
2016-01-05T11:33:20.690547+08:00 localhost systemd: Started worker.
2016-01-05T11:33:24.015147+08:00 localhost systemd: Stopping worker...
2016-01-05T11:34:04.422744+08:00 localhost systemd: Reloading.
2016-01-05T11:34:04.461630+08:00 localhost systemd: [/usr/lib/systemd/system/dm-event.socket:10] Unknown lvalue 'RemoveOnStop' in section 'Socket'
2016-01-05T11:34:04.468717+08:00 localhost systemd: [/usr/lib/systemd/system/lvm2-lvmetad.socket:9] Unknown lvalue 'RemoveOnStop' in section 'Socket'
2016-01-05T11:34:09.230960+08:00 localhost systemd: Starting worker...
2016-01-05T11:34:09.250545+08:00 localhost systemd: Starting worker...
2016-01-05T11:34:14.096035+08:00 localhost systemd: Starting worker...
2016-01-05T11:34:14.097725+08:00 localhost systemd: Started worker.
2016-01-05T11:37:24.367278+08:00 localhost systemd: Stopping worker...
2016-01-05T11:37:24.422634+08:00 localhost systemd: Stopped worker.
2016-01-05T11:42:12.381554+08:00 localhost systemd: Starting worker...
2016-01-05T11:42:12.382901+08:00 localhost systemd: Started worker.
2016-01-05T11:42:18.964033+08:00 localhost systemd: Reloading.

 

(本頁面已被瀏覽過 480 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料