Automated task execution tools in Linux

Source: Internet
Author: User
Article Title: Automatic task execution tool in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Red Hat Enterprise Linux tool with several automated tasks: cron, at, and batch.

  I. cron

Cron is a daemon that can be used to schedule the execution of repeated tasks based on the combination of time, date, month, and week.

Cron assumes that the system continues to run. If the system does not run when a task is scheduled, the task will not be executed.

To use the cron service, you must install the vixie-cron RPM package and run the crond service. To determine whether the software package is installed, run the rpm-q vixie-cron command. To determine whether the service is running, run the/sbin/service crond status Command.

1. configure a cron task

The main configuration file of cron is/etc/crontab, which includes 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 rows are variables used to configure the running environment of the cron task. The SHELL variable value tells the system which shell environment to use (bash shell in this example); the PATH variable defines the PATH used to execute commands. The cron task output is mailed to the username defined by the MAILTO variable. If the MAILTO variable is defined as a blank string (MAILTO = ""), the email will not be sent. The HOME variable can be used to set the HOME directory used for executing commands or scripts.

Each row in the/etc/crontab file represents a task. Its format is:

Minute hour day month dayofweek command

Minute-minute, any integer between 0 and 59

Hour-hour, any integer between 0 and 23

Day-date, any integer between 1 and 31 (if a month is specified, it must be the valid date of the month)

Month-month, any integer from 1 to 12 (or use the abbreviated month as jan, feb, and so on)

Dayofweek-any integer between 0 and 7 in a week. Here, 0 or 7 represents Sunday (or the abbreviation of a week, such as sun or mon)

Command-the command to be executed (the command can be ls/proc>/tmp/proc or a command to execute your own script .)

In any of the preceding values, the asterisk (*) can be used to represent all valid values. For example, the asterisk in the month value means that this command is executed every month after other constraints are met.

The short line (-) between integers specifies an integer range. For example, 1-4 means integers 1, 2, 3, and 4.

Specifies a list of values separated by commas. For example, 3, 4, 6, and 8 indicate the four specified integers.

A forward slash (/) can be used to specify the interval. Add/after the range/ This means that integer can be skipped within the range. For example, 0-59/2 can be used to define every two minutes in the minute field. The interval value can also be used with the star number. For example, the value of */3 can be used in the month field to indicate that a task runs every three months.

[1] [2] [3] [4] [5] [6] Next page

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.