UNIX System Administration Handbook - Evi Nemeth [105]
-exec /bin/rm -rf {} ';'
This command recursively removes all subdirectories of /tmp not modified in 72 hours. Plain files in /tmp are removed at boot time by the system startup scripts, but some systems do not remove directories. If a directory named lost+found exists, it is treated specially and is not removed. This is important if /tmp is a separate filesystem. See page 138 for more information about lost+found.
If you use any of these commands, you should make sure that users are aware of your cleanup policies.
Network distribution of configuration files
If you are running a network of machines, it’s often convenient to maintain a single, network-wide version of configuration files such as the mail aliases database (usually /etc/mail/aliases). Master versions of these files can be distributed every night with rdist or an expect script.
See Chapter 18 for more information about sharing configuration files.
Sometimes, postprocessing is required. For example, many systems require you to run newaliases to convert a text file of mail aliases to the hashed format used by sendmail. You might also need to load files into an administrative database such as NIS or NIS+.
Rotating log files
UNIX log files generally grow without bound until they are manually reset. There are various ways to prevent logs from overflowing, the simplest being to simply truncate them at periodic intervals.
A more conservative strategy is to “rotate” log files by keeping several older versions of each one. This scheme prevents log files from getting out of control but never leaves you without any recent log information. Since log rotation is a recurrent and regularly scheduled event, it’s an ideal task for cron. See Rotating log files on page 205 for more details.
9.5 VENDOR SPECIFICS
The locations of the various files and directories related to cron are summarized in Table 9.2, and system-specific details follow.
To turn on logging under Solaris, edit /etc/default/cron and set CRONLOG=YES. This configuration file also allows you to set the value of the PATH environment variable passed to commands.
Red Hat and FreeBSD use “Vixie-cron,” a freely available implementation of cron written by Paul Vixie. It provides several enhancements over most standard crons. For example, Vixie-cron allows you to specify the values of environment variables within a crontab file.
One especially useful feature of Vixie-cron is that it allows step values in crontab time specifications. For example, the series 0,3,6,9,12,15,18,21 can be written more concisely in Vixie-cron as 0-21/3.
See the man pages for cron and crontab for more information.
2. Some versions of cron permit shells other than sh to be used as well.
3. That is, the user after whom the crontab file is named. The actual owner of crontab files is generally root.
4. The word “core” means “memory.” This term originated on early computer systems, which used little ferrite donuts mounted on a woven mesh as memory elements.
5. Not all versions of find support the -xdev argument. On some systems, it’s called -x.
10 Backups
At most sites, the information stored on computers is worth more than the computers themselves. It is also much harder to replace. Protecting this information is one of the system administrator’s most important (and, unfortunately, most tedious) tasks.
There are hundreds of creative and not-so-creative ways to lose data. Software bugs routinely corrupt data files. Users accidentally delete their life’s work. Hackers and disgruntled employees erase disks. Hardware problems and natural disasters take out entire machine rooms.
If executed correctly, backups allow the administrator to restore a filesystem (or any portion of a filesystem) to the condition it was in at the time of the last backup. Backups must be done carefully and on a strict schedule. The backup system and backup media must also be tested regularly to verify that they are working correctly.
The security of dump tapes directly affects your