Sunday 19 July 2009

include date info while logging messages

Most of us now the date command to produce date output and using it to log date output to a log file while writing some information.I thought of using it this way for my log file to look like this:

tail -f ../logs/copy_to_lab.log
Mon Jul 13 12:18:08 PM : finished copying abc-tgz.done file


I have dumped the above information in this way:

echo "`date "+%a %b %d %X"` : $@" >> $HOME/logs/copy_to_lab.log

No comments:

Post a Comment

Tweets by @sriramperumalla