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.







December 14th, 2007 at 9:43 pm
Thanks, very useful!!!
February 26th, 2008 at 11:25 pm
I have a doubt.How do I write a a message from my program to /var/log/messages ? Is this possible? How?
February 27th, 2009 at 3:21 pm
Thank you so much
August 5th, 2011 at 9:40 pm
get and get big save for more detail