Pages

Monday, March 20, 2017

About Logger Command

List of Topics

1) What is Logger

2) Examples of Logger with options
3) Where it can be used

1) What is Logger

logger - a shell command interface to the syslog system log module. In simple logger command can be used to add a message to /var/log/messages(by default)  and configurable to other files also. Below are some of the options of logger with example

Logger will exit with 0 on success, and greater than 0 in case of any errors.

2) Examples of Logger with options

Without any option logger will print the message in "messages" file like below.

# logger "hi test"
Output entry in messages : Mar 21 05:32:08 lapp02 bhr_moham607: hi test

a) - i  = Print the process id of the “logger” process.
Eg) for Option -i
# logger -i "test: print pid"

Output entry in messages : Mar 21 06:00:17 lapp02 bhr_moham607[2199]: test: print pid
In the above output 2199 is the PID of the logger.

b) -t tag   = Add the tag will printing the message in the logger.
Eg) for Option -t


# logger -t "TAG test" -i "test message"

Output entry in messages : Mar 21 05:55:48 lapp02 TAG test[1957]: test message




3) Where it can be used

Logger will be mainly useful while automating the task in background and also also while working with shell script.

No comments:

Post a Comment