Linux

記錄器+如何更改記錄器標題而不是使用者根

  • March 4, 2019

我想為我的日誌使用日誌 - /var/log/message 我的應用程序名稱是 - whatsapp_man

例如,我將以下警告發送到日誌

[root@worker01 ~]# logger "please noitce you are before attack"
[root@worker01 ~]# tail -1 /var/log/messages
Mar  4 13:28:05 worker01 root: please notice you are before attack
[root@worker01 ~]#

但是如何使用記錄器來獲取whatsapp_man而不是root

作為福林的預期結果

[root@worker01 ~]# logger [....] "please notice you are before attack"
[root@worker01 ~]# tail -1 /var/log/messages
Mar  4 13:28:05 worker01  whatsapp_man: please notice you are before attack
[root@worker01 ~]#

您要查找的前綴由-tlogger 的選項提供:

logger -t whatsapp_man "..."

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