462
◾
Linux with Operating System Concepts
by separating the different recurrences with a slash (/).
Below are some examples of
crontab entries. We cover crontab in more detail in Chapter 14.
•
0 12 * 15 * ./foobar
—run the script foobar at 12 noon on the 15th of
every month
•
0 0 1 1 * ./foobar
—run the script foobar on January 1 at midnight (once
per year)
•
30 15 * * 6 ./foobar
—run the script foobar every Saturday at 3:30 pm
(15
=
3 pm in military time)
•
0/15/30/45 * 1 1 * ./foobar
—run the script foobar on January 1 every
15 min of every hour
As stated earlier, a scheduled job missed because of downtime does not get exe-
cuted when the system is brought back up. Instead, if the job is critical enough, it
should be scheduled with anacron.
• cups—the common Unix printing system is used to control print jobs on the printers
connected to a Linux computer. The printers may be directly connected to the com-
puter or available via a network even if the network consists of computers running
different versions of Linux or Unix. In Chapter 8, we briefly looked at how to install a
printer on a Linux computer, the result of which is a configuration file storing infor-
mation about the installed printer. In addition, installing a printer requires that the
proper device driver for the printer is installed. When the user issues a printer com-
mand (
lp
,
lpr
,
lpq
,
lprm
), cups takes over to handle
the command by accessing
the appropriate printer. An additional command,
lpc
, allows you to alter a printer’s
properties (this is also available via the Printer Configuration GUI).
• dnsmasq—this service is something like a mini-DNS server for Linux (DNS was
introduced in Chapter 5 and is also explored in Chapters 12 and 15). The role of
dnsmasq is threefold, all of which revolve around caching DNS information. First,
it caches responses from DNS server access so that further repeated accesses can
be handled locally while the entries remain stored in cache. Second, it uses the /etc/
hosts file, which contains specific IP alias to address mapping as set up by the sys-
tem administrator to bypass DNS server access. Third, it responds to requests from
DHCP servers regarding IP alias to IP address mappings. With dnsmasq, we reduce
the amount of access to the DNS server and thus reduce waiting time in Internet-
based communication. The service uses /
etc/dnsmasq.conf
as a configuration
file to specify details such as a DNS server to query in case the local cache does not
contain the relevant information, what network interface(s) to use (e.g., eth1 for any
DHCP requests), and the amount of time that items should remain cached.
• iptables and ip6tables—these are the Linux firewall for IPv4 and IPv6 messages,
respectively. The names of the services are also the names of a file of firewall rules,
which are located in /etc/sysconfig. In addition to the rules files of
iptables
and
System Initialization and Services
◾
463
ip6tables
, the configuration files are
iptables-config
and
ip6tables-
config
. We explore specific firewall rules in Chapter 12.
• logrotate—this service performs operations on log files, including rotating logs files,
compressing log files, and emailing log files. Log rotation renames the current log file
(usually stored under /var/log) and creates a new log file so that no log file grows too
large. Typically, log files are rotated automatically based on some rotation rate such as
weekly or monthly. Often, log files’ names are affixed with either a date or a number
indicated their age,
for instance, mylog (the current log file), mylog.1, mylog.2, and
mylog.3 (older log files of one, two, and three rotations in the past). The subdirectory
/
etc/logrotate.d
contains numerous configuration files, one per type of log file.
Each of these configuration files lists specific log files (e.g., /
var/log/messages
)
followed by a series of directives for handling that group of log files such as the maxi-
mum size of a log file, the rotation rate, the number of log files to retain, and so forth.
• nfs—permits the exportation of file systems for remote mounting. The system admin-
istrator places file system information in the /
etc/exports
file. For each file system
that can be remotely mounted, the entry must include the file system’s local mount
point, the location(s) where the file system can be remotely mounted (this might be *
to indicate anywhere, or specific or partial URLs or IP addresses as in 10.11.12.0/24
meaning any computer in the network 10.11.12) and any
options for the file system
such as ro (read only) and sync. We examined NFS in Chapter 10.
• syslogd—there are two other logging services of note, syslogd, and klogd. The klogd
service logs kernel messages and is not configurable. The syslogd service logs nonker-
nel operating system messages. It is configurable and can also be set up to log kernel
messages and application software messages. The syslogd daemon has a configuration
file, /
etc/syslog
. We explore how to configure syslogd in Section 11.7. It should be
noted that the most recent versions of Linux have renamed the daemon to rsyslogd
and the configuration file to
/etc/rsyslog
.
Another service of note is called
oddjobd
. Service requests are made by the user or
system administrator,
the operating system, external messages coming in from the net-
work, or other software. In some cases, software will not have permissions to execute a
given service. The oddjobd service provides a mapping so that specific software can make
requests of specific services.
The above list describes only some of the many services available. Missing from the
above discussion, among others, are services dealing with the computer network, port
mapping, and discovering the network router. Many of these network services are explored
in Chapter 12.
11.5.3 Starting and Stopping Services
As a system administrator, it will be your task to handle services.
Your options are to
start or stop services, and to reconfigure them. Decisions include whether a service
464
◾
Linux with Operating System Concepts
should be running at all times or on demand, whether a service should start at system
initialization time (recall the rc.conf script from Section 11.4 that started and stopped
services based on runlevel), or whether a service should not be run. And then, you will
have to determine whether to use the default configuration or alter the configuration of
a service. We examine how to start and stop services here, saving configuration for the
next two sections.
There are usually four different things you can do to a service: start, stop, restart, or
obtain the service’s status. You can control the service from either a GUI program or from
the command line. The service configuration tool allows you to
select any service and view
its status, start, stop, or restart it. Although it is called a
Do'stlaringiz bilan baham: