BSD DevCenter
oreilly.comSafari Books Online.Conferences.


Understanding the Automatons
Pages: 1, 2, 3

Let's continue by taking a look at the daily scripts. You'll note there is a logic to the layout of the scripts: The first scripts clean out old files, these are followed by backup scripts, which are followed by scripts which run some useful utilities.

# 100.clean-disks
daily_clean_disks_enable="NO"      # Delete files daily
daily_clean_disks_files="[#,]* .#* a.out *.core *.CKP .emacs_[0-9]*"
daily_clean_disks_days=3           # If older than this
daily_clean_disks_verbose="YES"    # Mention files deleted

This script is disabled by default but you may want to consider enabling it if disk space is an issue on your system. If you do enable this option, backup your important files first and check the output to ensure this script didn't delete any files you were attached to. This is especially important if you decide to add your own extensions to the files list.

The next script is also disabled by default and may be worth enabling if disk space is an issue:

# 110.clean-tmps
daily_clean_tmps_enable="NO"      # Delete stuff daily
daily_clean_tmps_dirs="/tmp"      # Delete under here
daily_clean_tmps_days="3"         # If not accessed for
daily_clean_tmps_ignore=".X*-lock quota.user" 
    # Don't delete these
daily_clean_tmps_verbose="YES"    # Mention files deleted

Related Reading

UNIX Power ToolsUNIX Power Tools
By Jerry Peek, Tim O'Reilly & Mike Loukides
Table of Contents
Full Description

Before enabling the clean-tmps script, you should be aware that there is a security advisory regarding this script which may affect you, depending on which version of FreeBSD you are running. If you're not yet aware of FreeBSD's security advisories (SAs), you should bookmark and spend some time reading this site.

And, as mentioned at this URL, subscribe to one of the mailing lists that the security advisories are sent to so you will be aware of any new exploits as they are found and fixed. The security advisory that deals with this particular script is FreeBSD-SA-01:40.fts.v1.1.asc.

The next script cleans out /var/preserve. If you don't know what a directory does on your FreeBSD system, man hier is the best place to look. Here I'll search that man page for the word "preserve":

man hier
preserve/  temporary home of files preserved after 
           an accidental death of an editor; see (ex)1

Now that you know what preserve is for, you can decide whether or not to keep this script enabled.

# 120.clean-preserve
daily_clean_preserve_enable="YES"   # Delete files daily
daily_clean_preserve_days=7         # If not modified for
daily_clean_preserve_verbose="YES"  # Mention files deleted

The next script cleans out messages sent by the msgs utility. If you don't use this utility, you can disable this script as there won't be any messages to delete. If you're not sure if you're using this utility, you probably aren't, but you can doublecheck by reading man msgs.

# 130.clean-msgs
daily_clean_msgs_enable="YES"   # Delete msgs daily
daily_clean_msgs_days=          # If not modified for

For the next script, it is again helpful to read the man page for the utility, in this case rwho. If your FreeBSD computer is not hooked up to a Unix LAN, you can disable this script as /var/rwho will always be empty.

# 140.clean-rwho
daily_clean_rwho_enable="YES"   # Delete rwho daily
daily_clean_rwho_days=7         # If not modified for
daily_clean_rwho_verbose="YES"  # Mention files deleted

You may or may not have a hoststat on your computer. To see why, check out this thread.

I don't, so I've disabled this script on my computer.

# 150.clean-hoststat
daily_clean_hoststat_enable="YES"   # Delete .hoststat daily
daily_clean_hoststat_days=3         # If not modified for
daily_clean_hoststat_verbose="YES"  # Mention files deleted

Now we get to the three backup scripts. You definitely want your password and group files backed up daily. This script not only backs them up, it will also report if either of those two files had any changes made to them that day. The output of this script should be checked on a daily basis.

# 200.backup-passwd
daily_backup_passwd_enable="YES"  # Backup passwd & group

It is a good idea to have a backup of your mail aliases file; whether or not you want to have it backed up daily is up to you.

# 210.backup-aliases
daily_backup_aliases_enable="YES"  # Backup mail aliases

Unless you are using rdist to maintain identical copies of files over multiple hosts, you won't have an /etc/Distfile and you can disable the script that backs it up.

# 220.backup-distfile
daily_backup_distfile_enable="YES"  # Backup /etc/Distfile

The calendar utility is interesting, but not enabled by default. If you like the fortune program and enjoy reading trivia, you might consider running the calendar program. There are a few steps involved in setting up calendar.

First, decide which calendar file you think you or your users would enjoy reading. The possible files are found in /usr/share/calendar:

cd /usr/share/calendar
ls -F .
../				calendar.judaic
calendar.birthday		calendar.russian
calendar.christian		calendar.usholiday
calendar.croatian		de_DE.ISO_8859-1/
calendar.german			hr_HR.ISO_8859-2/
calendar.history		ru_SU.KOI8-R/

Each of the files are in plain text so you can safely send them to a pager to see their contents or edit the contents as you wish. Some calendar files contain the actual trivia:

01/01&bnsp; AT&T officially divests its local Bell companies, 1984
01/01&bnsp; The Epoch (Time 0 for UNIX systems, Midnight GMT, 1970)
01/03&bnsp; Apple Computer founded, 1977
01/08&bnsp; American Telephone and Telegraph loses antitrust case, 1982
01/08&bnsp; Herman Hollerith patents first data processing computer, 1889
01/08&bnsp; Justice Dept. drops IBM suit, 1982
01/10&bnsp; First CDC 1604 delivered to Navy, 1960
01/16&bnsp; Set uid bit patent issued, to Dennis Ritchie, 1979
01/17&bnsp; Justice Dept. begins IBM anti-trust suit, 1969 (drops it, 01/08/82)
01/24&bnsp; DG Nova introduced, 1969

While other calendar files are used to specify which trivia files to include:

more calendar.all
#include <>
#include <calendar.german>
#include <calendar.usholiday>
#include <calendar.croatian>
#include <calendar.russian>

Any user aware of this directory can see what trivia is suited to today's and tomorrow's date by invoking the desired calendar file with the f switch like so:

calendar -f calendar.birthday
Nov  4 	King William III of Orange born, 1650
Nov  5 	Roy Rogers born, 1912

By default, if a user isn't in this directory or doesn't specify the full path name to the desired calendar file, they'll receive this error message:

calendar -f calendar.birthday
calendar: no calendar file: ''calendar.birthday'' or ''~/.calendar/calendar.birthday

To fix this, tell the user to create a directory in their home directory and to copy the desired calendar file(s) to it:

mkdir .calendar
cp /usr/share/calendar/ .calendar/calendar

I like as it includes birthdays, computer, music, history, and holidays. Since I've saved the file as "calendar", I can now simply type calendar with no arguments, regardless of what directory I'm in:

Nov  4  King William III of Orange born, 1650
Nov  5  Roy Rogers born, 1912
Nov  4  UNIVAC I program predicts Eisenhower victory based on 7% of votes, 1952
Nov  4  Iranian militants seize US embassy personnel in Teheran, 1979
Nov  4  Soviet forces crush the anti-communist revolt in Hungary, 1956
Nov  5  Guy Fawkes' Plot, 1605
Nov  4  Flag Day in Panama
Nov  4  Will Rogers Day

Which brings us back to the periodic script that deals with calendar. If you enable this script, it will email the customized calendar output to every user who has created a .calendar file in their home directory. As a side note, the superuser can do this at any time. Once you've set up your calendar directory, become the superuser and type:

calendar -a

If you check your email, you'll have a new message with a subject of "Day_of_the_Week Calendar". If your users think this is a cool feature, enable the periodic script and show them how to set up their calendar directory.

# 300.calendar
daily_calendar_enable="NO"   # Run calendar -a

Let's stop here for this week and we'll finish looking at the rest of the periodic scripts in the next article.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.

Read more FreeBSD Basics columns.

Return to the BSD DevCenter.

Sponsored by: