Documentation for "expecto"

Download the whole documentation as one plain text file


3. Usage and Options

3.2. Step-by-Step Instructions

These are step-by-step instructions to reduce and filter the output of the periodic cron jobs ("daily run", "weekly run", "monthly run") on FreeBSD 9.1. For other versions of FreeBSD you might have to adapt the templates. I think FreeBSD 8.x would require only minimal changes, if any.

1.

Make sure you have downloaded and installed expecto as explained in the "Installation" chapter. Please verify that it works, i.e. typing "expecto" should print a hint regarding the -h option.

The following assumes that expecto is installed in /usr/local/sbin.

2.

Create a directory for your templates:

mkdir /usr/local/etc/expecto

3.

Download template files and put them in the directory that you just created. The file names should be simply "daily", "weekly" and "monthly", respectively.

Template for "daily run"
Template for "weekly run"
Template for "monthly run"

4.

Perform the following simple test:

Type the command "expecto daily" and press Enter. Then type a random string like "foo bar" and press Enter. Finally press Ctrl+D. You should get the following output:

One or more sections of the daily run output did not match any expected pattern. These sections are copied below. Please check them carefully. -------- BEGIN -------- foo bar --------- END --------- Everything else matched expected patterns and is not included here. The complete daily run output can be found in /var/log if needed.
5.

Add the following lines to /etc/periodic.conf:

daily_status_security_inline="YES"
daily_output=""
weekly_output=""
monthly_output=""

If that file doesn't exist, create it and put the above lines in it, otherwise just append them to the existing content. If the file already exists and has other entries that augment the periodic run output, you might have to adapt the templates, so they match the additional output.

6.

Edit the file /etc/crontab. Locate the lines that execute the periodic cron jobs. Normally they look like this:

1 3 * * * root periodic daily
15 4 * * 6 root periodic weekly
30 5 1 * * root periodic monthly

Modify them as follows. Note that the following are supposed to be exactly three lines, even though your web browser might break them into more lines because they're rather long. Of course you can change the mail recipient if you want the messages to be sent to a different user instead of root. You can also change the mail subject.

1 3 * * * root periodic daily 2>&1 | tee -a /var/log/daily.log | /usr/local/sbin/expecto daily | mail -E -s "Daily run output" root 15 4 * * 6 root periodic weekly 2>&1 | tee -a /var/log/weekly.log | /usr/local/sbin/expecto weekly | mail -E -s "Weekly run output" root 30 5 1 * * root periodic monthly 2>&1 | tee -a /var/log/monthly.log | /usr/local/sbin/expecto monthly | mail -E -s "Monthly run output" root
7.

By default there are already entries in /etc/newsyslog.conf for rotating the daily, weekly and monthly log files in /var/log. You might want to review the file and check that the entries fit your need.

8.

Note that the templates probably need to be customized to your system. The next day, when you got a mail message from expecto, check the sections that it contains, and adapt the daily template accordingly.

If you did not get any mail -- Well, then be happy! In this case expecto works as expected. If you want to check that it really works, it's easy to provoke an entry: Just enter the "su" command and provide a wrong password. With the default syslog configuration, this causes an entry to be written to /var/log/auth.log that will be picked up by the daily run the next night.

If anything goes wrong, you can always check the complete output of the daily run in the file /var/log/daily.log.



[Valid XHTML 1.0]