Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Using cron to automate maintenance

The cron subsystem schedules tasks to run any hour of the day or night, making regular upkeep a breeze

Martin Streicher (martin.streicher@gmail.com), Chief Technology Officer, McClatchy Interactive
Photo of Martin Streicher
Martin Streicher is a freelance Ruby on Rails developer and the former Editor-in-Chief of Linux Magazine. Martin holds a Masters of Science degree in computer science from Purdue University and has programmed UNIX-like systems since 1986. He collects art and toys. You can reach Martin at martin.streicher@gmail.com.
(An IBM developerWorks Contributing Author)

Summary:  To leverage round-the-clock computing, tasks must run at all hours of the day. You could punctuate your sleep with waking interludes to log in and run this command or that command on dozens of machines, or you can enjoy your forty winks and turn the work over to the ubiquitous cron, a daemon, or perennial process, to execute commands on a schedule. From very often to every so often, cron happily minds the clock and runs jobs day or night. Learn how to configure and maintain cron, and discover just some of its many uses.

Date:  07 Oct 2008
Level:  Intermediate PDF:  A4 and Letter (69 KB)Get Adobe® Reader®

Activity:  18801 views
Comments:  

Before you start

Learn what to expect from this tutorial and how to get the most out of it.

About this tutorial

This tutorial explains how to configure and maintain cron, the job scheduler found on almost all UNIX® machines. Additionally, this lesson demonstrates just some of the many applications of cron.

Objectives

Learn how to create, schedule, and manage cron jobs and how to define timetables to control job frequency, from once per minute to once per year. Additionally, learn how to limit access to cron to prevent abuse and how to use other utilities in tandem with cron to automate common maintenance tasks.


Prerequisites

This tutorial is written for users and systems administrators of UNIX (and UNIX-like) systems. To follow this tutorial, you should have a general familiarity with a command-line shell and shell scripting. Some experience installing and configuring software on UNIX is also helpful.


System requirements

To run the examples in this tutorial, you need a UNIX computer. If you want to configure system-wide cron jobs, you also need root access. The examples shown in this tutorial are based on Vixie cron, which is used widely on modern UNIX systems, running on Ubuntu Desktop Linux® version 8.04.1. Other versions of cron are similar to Vixie; check the documentation for your UNIX system for specifics.

1 of 8 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=342930
TutorialTitle=Using cron to automate maintenance
publish-date=10072008
author1-email=martin.streicher@gmail.com
author1-email-cc=mmccrary@us.ibm.com