Main index

Introducing UNIX and Linux


Maintaining your Linux OS

Overview
Basic management
      Passwords
      Checking storage space
      Checking processes
      Managing users
      Shutting down and restarting your computer
      Automating tasks
Linux file management
      File compression and archiving tools
      File managers
      File splitters
Linux networking
      Getting started
      MAC and IP addresses
      Domain names
      Adding a Linux host to an existing network
      Building a private network
      Configuring the network interface
Security
Uninstalling Linux
Summary

Automating tasks

We discussed a facility called crontab for the automatic scheduling of repetitive tasks. This allows you to program an activity to be performed as often as every minute, or as infrequently as every year. When managing your system, crontab is an invaluable tool for performing tasks, such as backups, which are important for the system to run reliably, but which can be forgotten if left to you to perform yourself.

Worked example

How can Sam arrange for their mailbox to be backed up to .mailbackup in their home directory each morning at 6 am?
Solution: Sam should use crontab -e to edit their personal crontab file so that it includes:

# At 6.00am each day
# copy /var/mail/sam to ~sam/.mailbackup
0 6 * * * /bin/cp /var/mail/sam ~sam/.mailbackup

This will perform the file copy, and if any error message is generated, it will be mailed to Sam. Note the use of ~sam to denote Sam's home directory.

Many Linux distributions, including Red Hat and SuSE, include directories /etc/cron.hourly, /etc/cron.daily and /etc/cron.weekly. The executable scripts placed in these directories are run on an hourly, daily or weekly basis.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck