Using Cron for automatic maintenance

Source: Internet
Author: User
Tags garbage collection root access

Run tasks at any time through the Cron subsystem to easily implement routine maintenance

To achieve continuous computation, the task must be able to run at any time. You can wake up at night, log on to dozens of machines and enter commands, and rest safely and give the job to cron. Cron is a daemon, an uninterrupted process that executes commands according to the scheduling schedule. No matter how hard the day or night, regardless of how heavy the work, Cron will pay attention to time and run the homework on time without complaining. Learn how to configure and maintain cron to understand its many uses.

Before you start

This section explains what this tutorial teaches and how to derive maximum benefit from it.

About this tutorial

This tutorial explains how to configure and maintain Cron,cron is a job scheduler on almost all UNIX® computers. In addition, this tutorial demonstrates some of the other applications of Cron.

Goal

Learn how to create, schedule, and manage cron jobs, and how to control job frequencies by defining a schedule, from one time to every year. Also, learn how to restrict access to cron to avoid abuse, and how to combine other utilities and cron to automate common maintenance tasks.

Prerequisite conditions

This tutorial is for users and system administrators of Unix (and Unix-like) systems. To learn this tutorial, you should be familiar with command-line shell and shell scripts. It is also helpful to have the experience of installing and configuring software on UNIX.

System Requirements

To run the example in this tutorial, you need a UNIX computer. Root access is also required if you want to configure system-wide cron. The examples in this tutorial are based on Vixie Cron, which is widely used on modern UNIX systems, and using the Ubuntu Desktop linux®version 8.04.1. Other versions of Cron are similar to Vixie; see your UNIX system documentation for specific information.

Run without interruption

Unlike you and me, computers can work tirelessly and perform each task with the same energy. In addition, computers can work continuously 24 hours a day, 7 days a week, including snow days and public holidays.

Cron Daemon

However, to achieve continuous computation, the task must be able to run at any time. You can wake up at night, log on to dozens of machines and enter commands, and rest safely and give the job to cron. Cron is a daemon (that is, an uninterrupted process) that executes commands according to the scheduling schedule. No matter how hard the day or night, regardless of how heavy the work, Cron will pay attention to time and run the homework on time without complaining.

Do you need to monitor the data received by the FTP Dropbox (Drop-box)? Use cron to run a shell script every few minutes. Do you need to delete the daily backlog of draft files? Garbage collection is performed at midnight. Do you want the log files to be recycled periodically? Set up a weekly scheduling schedule.

Here, learn how to configure and maintain cron and learn about its many applications. Specifically, this tutorial discusses Vixie Cron,vixie the name originated from its developer, Paul Vixie. Vixie cron can be found on FreeBSD, Apple Mac OS X, most-styled Linux, and other UNIX systems. To find out if your system is running Vixie cron, you can enter man cron or man crontab to see if the developer is Paul Vixie at the end.

To learn this tutorial and use cron, you should be familiar with at least one text editor, such as VI or EMACS, and you should also have experience using UNIX command lines, shell scripts, and shell environment variables. Also, you must have root (superuser) access if you want to modify the system-wide cron configuration file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.