I used below options in script to print on terminal as well as /var/log/messages
echo "System Load is OK : $Current_loadadv" echo "System Load is OK : $Current_loadadv" | logger
but how can i do that in single line ?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
tee >(logger) <<< "System Load is OK : $Current_loadadv"
>(logger) is bash syntax to create a file descriptor that is going to a FIFO, which is then fed to the standard input of
logger (this is one form of what is known as "process substitution" in bash). It then passes back the path to that file descriptor as an argument to
tee, and since
tee writes to its non-option arguments, the FD is written to, and
logger receives your string.
Another Option :
logger -s "Message"
-s Log the message to standard error, as well as the system log.