Centos

從 systemctl status <service> 清除失敗狀態(或所有舊日誌)?

  • March 9, 2021

嘗試了不同的東西,但無法清除這個舊的整體/。當我跑

systemctl status httpd.service

結果:

Mar 09 09:28:08 il systemd[1]: httpd.service: control process exited, code=exited status=1
Mar 09 09:28:08 il systemd[1]: Failed to start The Apache HTTP Server.
Mar 09 09:28:08 il systemd[1]: Unit httpd.service entered failed state.
Mar 09 09:28:08 il systemd[1]: httpd.service failed.
Mar 09 19:27:59 il systemd[1]: Starting The Apache HTTP Server...
Mar 09 19:27:59 il systemd[1]: Started The Apache HTTP Server.

失敗狀態顯示為紅色,我想清除所有舊日誌條目。

試過:

systemctl reset-failed 
systemctl reset-failed httpd.service

但它不斷出現。

跑步CentOS Linux release 7.6.1810 (Core)

謝謝。

可以通過清除所有日誌日誌來完成:

sudo journalctl --rotate && sudo journalctl --vacuum-time=1s

或者:

sudo rm /var/log/journal/*/*.journal
sudo systemctl restart systemd-journald

引用自:https://unix.stackexchange.com/questions/638432