LogWatch

インストールすると自動的にcron設定してくれるようだ。

$ vim /etc/cron.daily/00logwatch

apt-get install logwatch

Logwatchのインストール

$ vim /etc/cron.daily/00logwatch

#!/bin/bash

#Check if removed-but-not-purged

test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0

#execute

/usr/sbin/logwatch --output mail

#Note: It's possible to force the recipient in above command

#Just pass --mailto address@a.com instead of --output mail

設定ファイルを/etc/logwatch/confにコピーする

cp /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/

cp /usr/share/logwatch/default.conf/services/* /etc/logwatch/conf/services/

設定ファイルを編集する

$ vim /etc/logwatch/conf/logwatch.conf

#Output/Format Options

#By default Logwatch will print to stdout in text with no encoding.

#To make email Default set Output = mail to save to file set Output = file

#Output = stdout

Output = mail

# Default person to mail reports to. Can be a local account or a

# complete email address. Variable Output should be set to mail, or

# --output mail should be passed on command line to enable mail feature.

#MailTo = root

MailTo = hoge@hoge.com

# The default detail level for the report.

# This can either be Low, Med, High or a number.

# Low = 0

# Med = 5

# High = 10

#Detail = Low

Detail = Med

/var/cache/logwatchを作成する

$ mkdir -p /var/cache/logwatch

確認

$ logwatch

指定したメールアドレスに届くことを確認する

rootユーザーでcrontab設定

$ crontab -e

# m h dom mon dow command

1 0 * * * /usr/sbin/logwatch $HOME/tmp/out 2>&1