Objective 4: Automate System Administration Tasks by Scheduling Jobs to Run in the Future

There is a surprising amount of housekeeping that must be done to keep a complex operating system such as Linux running smoothly. Log file rotation, cleanup of temporary files and directories, system database rebuilds, backups, and other tasks should be done routinely. Clearly such mundane things should be automated by the system, freeing weary system administrators for more interesting work. Fortunately, any system task that can be accomplished without real-time human intervention can be automated on Linux using the cron and at facilities. Both have the ability to execute system commands, which may start any executable program or script, at selectable times. Further, cron and at can execute these commands on behalf of any authorized system user. cron is intended mainly for regularly scheduled recurring activities, and at is most useful for scheduling single commands for execution in the future.

Using cron

The cron facility consists of two programs (There is no individual program called cron, which is the overall name given to the facility. If you execute man cron, however, you will see the manpage for crond.):

crond

This is the cron daemon. This is the process that executes your instructions. It starts at system initialization time and runs in the background thereafter.

crontab

This is the cron table manipulation program. This program gives you access to your cron table or crontab file. ...

Get LPI Linux Certification in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.