shantanuo
shantanuo

Reputation: 32286

error out to logger

I use logger command to log messages to /var/log/messages But How do I use logger to save the standard out, error out messages? Something like this does not work.

grep `date +'%y%m%d'` /var/log/mysqld.log | sed 's/^/computer /' | logger 2> logger

Upvotes: 0

Views: 244

Answers (1)

Brian Agnew
Brian Agnew

Reputation: 272357

You're confusing redirection to a process (pipes, or |) with redirection to a file (>).

You need to redirect stderr to stdout by using 2>&1, and then pipe (|) to your logger process.

e.g.

grep ....  2>&1 | logger

This assumes you're using sh or a variant. The syntax is different for csh. It's worth having a look at this excerpt from Unix Power Tools for more info (especially as your previous question seems strongly related).

Upvotes: 2

Related Questions