[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Logging of commands in a bash script to a file

On Tue, Apr 22, 2014 at 07:06:41PM -0300, Daniel Bareiro wrote:
> Hi all!
> I'm writing a bash script that runs several routing commands. I would
> like these commands, on a part of the script, plus run, are saved to a
> log file.

If you have bsdutils installed have a look at the "logger" command. It
will let your script send messages to the system logs, and you can
pipe command output into it for use in the log entry.

For example, if I type:
   date | logger

I get:
   Apr 22 20:13:47 hedorah dave: Tue Apr 22 20:13:47 MDT 2014
in /var/log/syslog.



Dave Thayer / Denver, Colorado USA / dave@thayer-boyle.com 
 Whenever you read a good book, it's like the author is right there, in
 the room talking to you, which is why I don't like to read good books.
 - Jack Handey "Deep Thoughts"

Reply to: