Results 1 to 5 of 5
Hi,
I have a script that archives some data to an external USB drive. I'm running this with a cron job so I want to log the result in a ...
- 02-01-2011 #1Just Joined!
- Join Date
- Jan 2011
- Posts
- 6
[SOLVED] logger -f option not working
Hi,
I have a script that archives some data to an external USB drive. I'm running this with a cron job so I want to log the result in a specific log file.
To do that I'm trying to use the logger function with the -f option.
man page says "-f file Log the specified file." I'm thinking that means logging to a specific log file but it does not work. The output ends up in /var/log/syslog.
Any ideas are appreciated.
Anders.
- 02-01-2011 #2Just Joined!
- Join Date
- Jan 2011
- Posts
- 6
Forgott to say I'm using Ubuntu Server 10.10
- 02-02-2011 #3
would you kindly show us your script? my magic crystal ball is broken.
- 02-02-2011 #4Just Joined!
- Join Date
- Jan 2011
- Posts
- 6
Hehe,
Well, I read the man page for logger on a solaris client today. It was somewhat more detaild.
The -f option means that logger reads the message from the file, not that it writes it to the file.
I put this 'workaround' inplace in the meantime.
#!/bin/bash
# Purpose: Archive client backup stored on samba share to external USB drive
# Setup source and target
BKPTARGET="/srv/backup/"
BKPSOURCE="/srv/samba2/share/"
# Run the rsync and log result
date +'%b %d %T -----Starting archiving of backup-----' >> /var/log/backup_rsyn c.log
rsync -avh $BKPSOURCE $BKPTARGET | sed "s/^/$(date +'%b %d %T ')/" >> /var/log/b ackup_rsync.log
date +'%b %d %T -----Finished archiving of backup-----' >> /var/log/backup_rsyn c.log
- 02-03-2011 #5When one reads it literally from top to bottom it clearly states that the logger logs to syslog ("logger — a shell command interface to the syslog(3) system log module") and the two examples show how to use it.$ man logger
LOGGER(1) BSD General Commands Manual LOGGER(1)
NAME
logger — a shell command interface to the syslog(3) system log module
SYNOPSIS
logger [-isd] [-f file] [-p pri] [-t tag] [-u socket] [message ...]
DESCRIPTION
Logger makes entries in the system log. It provides a shell command interface to the
syslog(3) system log module.
Options:
-i Log the process id of the logger process with each line.
-s Log the message to standard error, as well as the system log.
-f file Log the specified file.
-p pri Enter the message with the specified priority. The priority may be specified
numerically or as a ``facility.level'' pair. For example, ``-p local3.info''
logs the message(s) as informational level in the local3 facility. The
default is ``user.notice.''
-t tag Mark every line in the log with the specified tag.
-u sock Write to socket as specified with socket instead of builtin syslog routines.
-d Use a datagram instead of a stream connection to this socket.
-- End the argument list. This is to allow the message to start with a hyphen
(-).
message Write the message to log; if not specified, and the -f flag is not provided,
standard input is logged.
The logger utility exits 0 on success, and >0 if an error occurs.
Valid facility names are: auth, authpriv (for security information of a sensitive
nature), cron, daemon, ftp, kern, lpr, mail, news, security (deprecated synonym for
auth), syslog, user, uucp, and local0 to local7, inclusive.
Valid level names are): alert, crit, debug, emerg, err, error (deprecated synonym for
err), info, notice, panic (deprecated synonym for emerg), warning, warn (deprecated
synonym for warning). For the priority order and intended purposes of these levels,
see syslog(3).
EXAMPLES
logger System rebooted
logger -p local0.notice -t HOSTIDM -f /dev/idmc
SEE ALSO
syslog(3), syslogd(
If you want to log into another file, you'll have to use something else.
Code:# log a message # $1 level # $2 message function log { "`date` - ${1} - ${2}\n" >> /var/log/mylogfile.log } # usage log WARN "this is my warning"


