578
◾
Linux with
Operating System Concepts
files (and directories) that have been changed (modified, added to, and deleted) since the last
backup and apply the option
–g
filename
or --
listed-incremental
=
filename
.
The more recent archiving programs are
cpio
and
dump
. Both cpio and tar have an
advantage over dump in that you can select specific files or directories or both to archive
with either cpio or tar.
Additionally, tar allows you to specify criteria
for file selection while
cpio can use
find
to obtain the files to backup. For instance, we might want to back up
only text files or files created by a particular user.
Dump operates only on the level of file systems and so is unable to create an archive in a
piecemeal manner. There is also a
--newer
=
date
option available in tar that will backup
files newer than the supplied
date
(or alternatively, --
newer
=
file
where
tar stores files
newer than
file
).
All three programs (dump, cpio, and tar) can perform incremental backups. Both cpio
and tar have more primitive techniques for handling incremental backups though; so, we
might prefer to use dump. For tar, we mentioned above using a file to compare against the
stored files to determine recency. With cpio, you could use a find command as stated in
the previous paragraph, but in this case, use
–anewer
or
–cnewer
resulting in much the
same behavior.
Dump provides different levels of backup. A full backup is denoted as level 0. After mak-
ing
a full backup, you can next specify a different level that then performs a backup of all
changes to the file system up to the most recent incremental backup whose level is less than
the current level number. For instance, a follow-up backup of level 1 would find anything
new since the full backup. The next backup at level 2 would find all changes since the level
1 backup.
In addition, dump has a feature superior to tar and cpio in terms of indexing the con-
tents of an archive. While both tar and dump allow you to view the contents of an archive,
dump also lets you interactively find
and
restore specific files.
14.3
TASK SCHEDULING
As a system administrator, you will most likely want to schedule processes in an attempt
to further automate tasks. Scheduling may be for one-time execution or recurring in
some pattern such as daily, weekly, or monthly. By automating tasks through scripts and
scheduling them, you free your time up for other, more important tasks such as system
monitoring,
troubleshooting emergencies, and continuing education. There are many tools
available to schedule tasks. We have already explored or mentioned some of these. Here,
we will review them.
The earliest a task can be automated is when the system is initialized. Recall from
Chapter 11 that during initialization, the scripts in /
etc/rc.d
are executed. The last
script to execute during this process is
rc.local
. In this script, the system administra-
tor is able to specify his or her own initialization tasks that
were not performed by other
start-up scripts.
For instance, imagine that your Linux machine is to run a Squid proxy server. You may
wish to create the Squid caches and then start the proxy server. These start-up commands
can be placed in the rc.d script.
Maintaining and Troubleshooting Linux
◾
579
Another use of this script is to automatically mount remote file systems. This could be
a critical step in the initialization process if you are using remote file systems as part of or
all of /usr or /home.
There may be other tasks that you wish to run after initialization. These could include
• Log rotation
• Execution of scripts that obtain statistical information
• Data-mining
analysis on log files
• Examination of user disk space for poorly protected files, users who are using too
much space, files that have become corrupted, or files that might contain a virus
The next tool for scheduling activities is the
anacron
service. Anacron will examine
crontab
scheduled processes to see if any were supposed to execute during the downtime
from which you have just booted. If any are found, then they are executed. Anacron and
crontab are available to schedule recurring tasks. Additionally,
at
and
batch
are avail-
able to schedule one-time tasks.
For the remainder of this section, we will concentrate on how to use crontab and at for
scheduling. We start with at, which is the easier of the two to understand.
14.3.1 The at Program
The at program is used for one-time scheduling. The command requires that you specify
the time that the command should execute. The time includes both the date and the time
on that date. Time and date are indicated by either absolute values or relative to when the
command is being issued.
For an absolute specifier, the time format is
HH:MM
, optionally followed by
AM
or
PM
.
If AM or PM is omitted, then the time
is interpreted as being in
Do'stlaringiz bilan baham: