Date: Sun, 3 Oct 1999 02:51:55 -0400 (EDT) From: "Crist J. Clark" <cjc@cc942873-a.ewndsr1.nj.home.com> To: river@theriver.nu (river) Cc: cjclark@home.com ('cjclark@home.com'), questions@FreeBSD.ORG Subject: Re: syslog and mailing logs Message-ID: <199910030651.CAA06090@cc942873-a.ewndsr1.nj.home.com> In-Reply-To: <21DC5E98AE1FD311B1290020AFDB6C6E6460@DRIP> from river at "Oct 2, 1999 11:59:36 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
river wrote, > I.E in linux i can do the following with the log files: > > > /var/log/messages { > rotate 1 > size=10k > mail user@company.com > errors user@company.com > postrotate > /usr/bin/killall -HUP syslogd > endscript > } > > > I need to be able to do this in BSD Ahhh... From the looks of that config file, I would guess we are talking about a Red Hat utility. Ah, yes, logging onto a Red Hat system I have access to, I see that this is the 'logrotate' command's config file. The newsyslogd(8) command in FreeBSD does not have the built-in capability to send logs as email, it would be quite easy to create a shell script that does this for you. For example, #!/bin/sh # # mailsyslog # User(s) we wish to send log to RECP=user@company.com # Log file(s) we wish to send LOGS=/var/log/messages # Loop over the logs for LOG in $LOGS; do # We configured newsyslogd to create a <log>.0 file of what # we want to mail. Check if this file exists. if [ -f "$LOG".0 ]; then # Send it mail -s "$LOG at $HOST" $RECP < "$LOG".0 # Sent, delete it (we could compress it or something if we # did not want to delete it). rm "$LOG".0 fi done After you have put the script someplace like, /usr/local/libexec, you edit the /etc/crontab file so it is run right after newsyslogd. Edit the newsyslogd line like, # rotate log files every hour, if necessary 0 * * * * root newsyslog; /usr/local/libexec/mailsyslog That looks like it would do what you want. OTOH, Red Hat's logrotate would likely run on a FreeBSD system... -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910030651.CAA06090>