Linux: how to configure LogWatch to send an HTML weekly email instead of daily

If you wish to receive logwatch’s report on a weekly basis instead of daily you have two perform two basic tasks.

First, edit /etc/logwatch/conf/logwatch.conf and change:

Range = yesterday

into:

Range = between -7 days and -1 days

Also, to enable the HTML output, change:

Format = text

into:

Format = html

Second, move the cron script from the daily directory to the weekly directoru with this command:

mv /etc/cron.daily/00logwatch /etc/cron.weekly/

Testing LogWatch and fixing missing files

Before quitting test the scripts because there are two common problems that usually occurs.

Run /etc/cron.weekly/00logwatch  and check the output.

Problem 1: missing perl library

On some system you need to install the perl-DateManip library otherwise LogWatch will not understand the “Range” config directive.

If this happen on your system just install the perl library with the command:

apt-get install libdate-manip-perl

Problem 2: missing HTML templates

Since we enabled HTML output then LogWatch will look for an header and footer HTML template, if those files are not shipped with your distribution and if you get an error message about it then you have to manually create them.

Create the directory:

mkdir /usr/share/logwatch/default.conf/html/

After that you can create into this directory the two html templates.

As example you can use the following code for footer.html template:

</body></html>

And the following one for the header.html template:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Logwatch  $Version  ( $VDate )</title>
<meta name="generator" content="Logwatch  $Version ( $VDate )">
<style type="text/css">
h1 {color: gray; border-bottom: 3px double silver}
h2,h3 {color: gray; border-bottom: 1px solid silver}
.ref {padding-left: 1%}
.service {padding-left: 1%; font-family: Monospace}
.return_link {border-top: 1px; border-bottom: 1px;
padding: 1%; margin-top: 1%; margin-bottom: 1%;}
.copyright {color: black; border-top: 1px solid grey;
        border-bottom: 1px solid grey;
padding: 1%; margin-top: 1%; margin-bottom: 1%;}
</style>
</head>
<body style="width:90%; margin-left: 5%; margin-right: 5%" bgcolor="#FFFFFF">
<hr>
Linux: how to configure LogWatch to send an HTML weekly email instead of daily, 4.5 out of 5 based on 2 ratings

Potrebbe interessarti anche:

Iscriviti alla newsletter

  • HowTo e Tutorial su Linux e Ubuntu
  • Wordpress, Perl & Webmin
  • VoIP, Asterisk, SIP

Cosa stai aspettando?

Trackbacks