logcmd - Log the output of a program.


NAME

logcmd - Log the output of a program.


SYNOPSIS

  logcmd [options] -- <command> [command-args ...]


DESCRIPTION

logcmd logs the output of a program. This program is useful for logging program output for programs that do not have a built-in logging facility.

Typical usage is to use logcmd in crontabs to log any command output to a file instead of mail automatically being sent to the crontab owner.

When invoking logcmd, you must use ``--'' to separate the logcmd and its options from the command you are invoking. For example,

  logcmd -log out.log -- some-cmd arg1 arg2 arg3

This tells logcmd to run ``some-cmd arg1 arg2 arg3'' and have any output goto out.log.

Each line logged will be preceded by a timestamp, the process ID, and the name of the command. Also, before the first log message for a command is printed, logcmd will print out a line giving the full command-line of the command invoked. Example:

  [2002-07-30 14:52:13] [25392] logcmd: Command: [25393] mhonarc -quiet -out out /var/archiver/mail
  [2002-07-30 14:52:13] [25393] mhonarc: 
  [2002-07-30 14:52:13] [25393] mhonarc: Warning: Unrecognized character set: utf-8
  [2002-07-30 14:52:13] [25393] mhonarc:          Message-Id: <1022714308.2028.1.camel@xxx.xxx.xxx>
  [2002-07-30 14:52:13] [25393] mhonarc:          Message Number: 00367
  [2002-07-30 14:52:13] [25393] mhonarc: 
  [2002-07-30 14:52:13] [25393] mhonarc: Warning: Unrecognized character set: utf-8
  [2002-07-30 14:52:13] [25393] mhonarc:          Message-Id: <1022716087.2028.3.camel@xxx.xxx.xxx>
  [2002-07-30 14:52:13] [25393] mhonarc:          Message Number: 00368
  [2002-07-30 14:52:14] [25393] mhonarc: 
  [2002-07-30 14:52:14] [25393] mhonarc: Warning: Unrecognized character set: utf-8
  [2002-07-30 14:52:14] [25393] mhonarc:          Message-Id: <1024365245.9394.0.camel@xxx.xxx.xxx>
  [2002-07-30 14:52:14] [25393] mhonarc:          Message Number: 00398


OPTIONS

-help
Display SYNOPSIS and OPTIONS sections.

-log pathname
Command output will be logged to pathname. If this option is not specified, then standard out is used.

-man
Display manpage.

-time-fmt fmt
Date/time format to use when printing time before each logged line. The format string should be in strftime(3) format. If this option is not specified, then ``%Y-%m-%d %H:%M:%S'' is used.

--
Terminate option processing for logcmd. Any arguments after -- comprise the command that logcmd should execute.


EXAMPLES

The following is an example crontab entries of a user that has any output of commands goto a personal log file:

  0 2 * * * logcmd -log $HOME/log/cron.log -- $HOME/bin/clean_account
  0 3 * * * logcmd -log $HOME/log/cron.log -- $HOME/bin/pack_mail


LIMITATIONS


DEPENDENCIES

Getopt::Long, POSIX.


AUTHOR

Earl Hood, earl@earlhood.com

This program comes with ABSOLUTELY NO WARRANTY and may be copied only under the terms of the GNU General Public License.

 logcmd - Log the output of a program.