logger 命令用于在系统日志或者系统日志中记录消息。
我们可以在命令行上记录消息字符串或者提供一个文件作为输入,其中可以包含要记录的消息。
查看 logger 命令的可用开关:
# logger --help Usage: logger [options] [message] Options: -T, --tcp use TCP only -d, --udp use UDP only -i, --id log the process ID too -f, --file [file] log the contents of this file -h, --help display this help text and exit -S, --size [num] maximum size for a single message (default 1024) -n, --server [name] write to this remote syslog server -P, --port [port] use this port for UDP or TCP connection -p, --priority [prio] mark given message with this priority -s, --stderr output message to standard error as well -t, --tag [tag] mark every line with this tag -u, --socket [socket] write to this Unix socket -V, --version output version information and exit
https://onitroad.com 更多教程
记录器命令示例
- 将消息记录到标准错误和系统日志中
# logger -s "This is a test message"
- 将消息记录到指定文件
# logger -f file "This is a test message"
- 记录指定优先级的消息
# logger -p 1 "This is a test message"
- 用指定的标签标记每一行
# logger -t TAG "This is a test message"
- 允许消息以连字符开头
# logger -- "This is a test message"
日期:2020-09-17 00:14:28 来源:oir作者:oir