Làm thế nào tôi có thể viết một mục vào /var/log/syslogtừ dòng lệnh?
Làm thế nào tôi có thể viết một mục vào /var/log/syslogtừ dòng lệnh?
Câu trả lời:
Sử dụng loggerlệnh.
logger Some message to write
Có một số tùy chọn có sẵn, bao gồm:
-i Log the process ID in each line
-f Log the contents of a specified file
-n Write to the specified remote syslog server
-p Specify a priority
-t Tag the line with a specified tag
Xem man 1 loggerđể biết thêm thông tin về công cụ.
Ngoài ra, bạn có thể viết thư syslogtừ python:
python -c 'import syslog; syslog.syslog("Hello World")'
loggerlệnh này là gì?
logger. Bạn đã có phiếu bầu của tôi, tôi chỉ đề cập đến một sự thay thế.
loggerví dụ chi tiết hơn và để đăng nhập từ xa quanetcathoặc chuyển hướng shell, hãy xem: safaribooksonline.com/l