log personal message to /var/log/messages

August 14th, 2006 mysurface Posted in Admin, backquote, logger, tail | Hits: 75340 | 4 Comments »

To log personal messages to /var/log/messages when you write script, you can use logger

simple example:

logger i am testing

And check the result with tail, it display last 10 line of messages by default

tail /var/log/messages

To put more info to log file, you can specified the timestamp with scriptname by this

logger -t `basename $0` i am still testing

basename is to display scriptname without ./ or the parent’s path, back quote (`) is to pass the result string to logger.

4 Responses to “log personal message to /var/log/messages”

  1. Thanks, very useful!!!

  2. I have a doubt.How do I write a a message from my program to /var/log/messages ? Is this possible? How?

  3. devendra koli Says:

    Thank you so much

  4. DuevEbeverlee Says:

    get and get big save for more detail

Leave a Reply