Flylib.com

Books Software

 
 
 

Additional Resources


Additional Resources

Much more can be said about the XFree86 server, the clients that connect to it, and the assorted desktop environments and window managers. Advanced users interested in tweaking their XFree86 configuration will find these additional sources of information useful.

Installed Documentation

  • /usr/X11R6/lib/X11/doc/README — Briefly describes the XFree86 architecture and how to get additional information about the XFree86 project as a new user .

  • /usr/X11R6/lib/X11/doc/README.Config — Explains the advanced configuration options open to XFree86 version 3 users.

  • /usr/X11R6/lib/X11/doc/RELNOTES — For advanced users who want to read about the latest features available in XFree86.

  • man XF86Config — Contains information about the XFree86 configuration files, including the meaning of and syntax for the different sections within the files.

  • man XFree86 — The primary man page for all XFree86 information. Details the difference between local and network X server connections, explores common environmental variables , lists command-line options, and provides helpful administrative key combinations.

  • man Xserver — Describes the X display server.

Useful Websites

  • http://www.xfree86.org — Home page of the XFree86 project, which produces the XFree86 open-source version of the X Window System. XFree86 is bundled with Red Hat Linux to control the necessary hardware and provide a GUI environment.

  • http://dri. sourceforge .net — Home page of the DRI (Direct Rendering Infrastructure) project. The DRI is the core hardware 3D acceleration component of XFree86.

  • http://www.redhat.com/mirrors/LDP/HOWTO/XFree86-HOWTO — A HOWTO document detailing the manual installation and custom configuration of XFree86.

  • http://www.gnome.org — The home page of the GNOME project.

  • http://www.kde.org — The home page of the KDE desktop environment.

Related Books

  • The Concise Guide to XFree86 for Linux by Aron Hsiao (Que) — Provides an expert’s view of the operation of XFree86 on Linux systems.

  • The New XFree86 by Bill Ball (Prima Publishing) — Discusses XFree86 and its relationship with popular desktop environments, such as GNOME and KDE.

  • Beginning GTK+ and GNOME by Peter Wright (Wrox Press, Inc.) — Introduces programmers to the GNOME architecture, showing them how to get started with GTK+.

  • GTK+/GNOME Application Development by Havoc Pennington (New Riders Publishing) — An advanced look into the heart of GTK+ programming, focusing on sample code and a thorough look at the available APIs.

  • KDE 2.0 Development by David Sweet and Matthias Ettrich (Sams Publishing) — Instructs beginning and advanced developers how to take advantage of the many environment guidelines required to build Qt applications for KDE.



Chapter 10: Automated Tasks

Some tasks — particularly those that are processor- or disk- intensive — are best performed when system demand is low. This may be at a certain time of the day, week, or month, or when the system load is low. In addition, the administrator may find that automating repetitive tasks such as backups or disk space checks will significantly reduce personal workload.

In Linux, tasks can be configured to run automatically within a specified period of time, on a specified date, or when the system load average is below a specified number. Red Hat Linux comes preconfigured to run important system tasks to keep the system updated. For example, the slocate database used by the locate command is updated daily. A system administrator can use automated tasks to perform periodic backups, monitor the system, run custom scripts, and more. Red Hat Linux comes with four automated tasks utilities: cron, anacron, at, and batch.

cron

cron is a daemon that can be used to schedule the execution of recurring tasks according to a combination of the time, day of the month, month, day of the week, and week. cron assumes that the system is on continuously. If the system is not on when a task is scheduled, it is not executed. To configure tasks based on time periods instead of exact times, refer to the “at and batch” section of this chapter.

To use the cron service, you must have the vixie-cron RPM package installed, and the crond service must be running. To determine if the package is installed, use the rpm -q vixie-cron command. To determine if the service is running, use the command / sbin/service crond status .

Configuring cron Tasks

The main configuration file for cron, /etc/crontab , contains the following lines:

SHELL=/bin/bash

PATH

=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-

parts

/etc/cron.monthly

The first four lines are variables used to configure the environment in which the cron tasks are run. The value of the SHELL variable tells the system which shell environment to use (in this example, the bash shell), and the PATH variable defines the path used to execute commands.

The output of the cron tasks is emailed to the username defined with the MAILTO variable. If the MAILTO variable is defined as an empty string ( MAILTO="" ), email will not be sent. The HOME variable can be used to set the home directory to use when executing commands or scripts.

Each line in the /etc/crontab file represents a task and has the format:


minute

hour

day month dayofweek command

  • minute — any integer from 0 to 59

  • hour — any integer from 0 to 23

  • day — any integer from 1 to 31 (must be a valid day if a month is specified)

  • month — any integer from 1 to 12 (or the short name of the month such as jan , feb , and so on)

  • dayofweek — any integer from 0 to 7, where 0 or 7 represents Sunday (or the short name of the week such as sun , mon , and so on)

  • command — the command to execute. The command can either be a command such as ls /proc >> /tmp/proc or the command to execute a custom script that you wrote.

For any of the above values, an asterisk ( * ) can be used to specify all valid values. For example, an asterisk for the month value means execute the command every month within the constraints of the other values. A hyphen ( - ) between integers specifies a range of integers. For example, 1-4 means the integers 1, 2, 3, and 4. A list of values separated by commas ( , ) specifies a list. For example, 3, 4, 6, 8 indicates those four specific integers.

The forward slash ( / ) can be used to specify step values. The value of an integer can be skipped within a range by following the range with / integer . For example, 0-59/2 can be used to define every other minute in the minute field. Step values can also be used with an asterisk. For instance, the value */3 can be used in the month field to run the task every third month.

Any lines that begin with a hash mark ( # ) are comments and are not processed . As you can see from the /etc/crontab file, it uses the run-parts script to execute the scripts in the /etc/cron.hourly , /etc/cron.daily , /etc/cron.weekly , and /etc/cron.monthly directories on an hourly, daily, weekly, or monthly basis respectively. The files in these directories should be shell scripts.

If a cron task needs to be executed on a schedule other than hourly, daily, weekly, or monthly, it can be added to the /etc/cron.d directory. All files in this directory use the same syntax as /etc/crontab . Here is an example:

# record the memory usage of the system every Monday # at 3:30AM in the file /tmp/meminfo 30 3 * * mon cat /proc/meminfo >> /tmp/meminfo # run custom script the first day of every month at 4:10AM 10 4 1 * * /root/scripts/backup.sh

Users other than root can configure cron tasks by using the crontab utility. All user -defined crontabs are stored in the /var/spool/cron directory and are executed using the usernames of the users that created them. To create a crontab as a user, log in as that user and type crontab -e to edit the user’s crontab using the editor specified by the VISUAL or EDITOR environment variable. The file uses the same format as /etc/crontab . When the changes to the crontab are saved, the crontab is stored according to username and written to the file /var/spool/cron/username .

The cron daemon checks the /etc/crontab file, the /etc/cron.d/ directory, and the /var/spool/cron directory every minute for any changes. If any changes are found, they are loaded into memory. Thus, the daemon does not need to be restarted if a crontab file is changed.

Controlling Access to cron

The /etc/cron.allow and /etc/cron.deny files are used to restrict access to cron. The format of both access control files is one username on each line. Whitespace is not permitted in either file.

The cron daemon ( crond ) does not have to be restarted if the access control files are modified. The access control files are read each time a user tries to add or delete a cron task. The root user can always use cron, regardless of the user names listed in the access control files.

If the file cron.allow exists, only users listed in it are allowed to use cron, and the cron.deny file is ignored. If cron.allow does not exist, all users listed in cron.deny are not allowed to use cron.

Starting and Stopping the Service

To start the cron service, use the command /sbin/service crond start . To stop the service, use the command /sbin/service crond stop . It is recommended that you start the service at boot time.