Scheduling task management in Linux

Source: Internet
Author: User

In the Linux operating system, in addition to the user's immediate execution of command operations, you can also configure pre-scheduled system administration tasks (such as regularly backing up data, periodically opening services, and so on) at a specified time and on a specified date.

The scheduled task in the RedHat 6.5 system is a set of scheduled tasks by the AT, crontab commands, where the AT command is a one-time scheduled task, and the Crontab command is a recurring scheduled task.
(1) at command (one-time execution Task)
Scheduled tasks that are set using the AT command are performed only once at a specified point in time, as long as the ATD system service needs to be turned on, the time that the scheduled task needs to be set, the date must be after the current system time, or the scheduled task will not be set up correctly.
When you set up a one-time scheduled task, at the AT command line, specify a schedule task at once, the date as the parameter (if only the specified time represents the time of the day, if only the specified date represents the current time of the date), the confirmation will enter the task editing interface with the "at>" prompt, each line set an execution command, You can set more than one statement in turn, and then press Ctrl+d to submit the task.

Example: Schedule automatic shutdown of the current system at 22:00 tomorrow

For scheduled tasks that have been set up for scheduled tasks but not performed, you can query through the ATQ command

To remove the at task, you can use the ATRM command, and the at task will not be executed and will not appear in the display results of the ATQ command

(2) crontab command (recurring tasks)
The scheduled tasks set with the crontab command can be repeated on a pre-defined cycle, greatly reducing the set of repetitive system administration tasks, provided by the package Cronie crontab tools, System Services Crond, and configuration files/etc/crontab.
The common options for the Crotab command are as follows:
-E: Edit Scheduled Task List
-U: Specifies which user the managed scheduled task belongs to and, by default, for the current user, typically only the root user has permission to use this option (for editing, deleting other users ' scheduled tasks)
-L: List shows scheduled tasks
-R: Delete Scheduled Task List

Each row still has no configuration records that contain six data fields, each representing a different meaning, and each field must be defined, as

The first five data fields can be represented using the following symbols
Asterisk "*": Indicates any time in the range of values
Minus "-": represents a continuous range of time
Comma ",": a discontinuous range that represents an interval

Example: Use the tar command to automatically back up the/ETC/HTTPD directory every day 0:00


View the list of scheduled tasks for the current user

Delete the current user's Scheduled Tasks list
When you delete a scheduled task, you can edit it through crontab–e; To clear all scheduled tasks for the current user, execute the crontab–r command

Precautions:
Timed tasks (generally referred to as script tasks) the end of the rule should preferably add ">/dev/null 2>&1", that is, do not output any information, if not added, a long time, will produce a large number of files to occupy a large number of disk inode nodes, so that the disk inode full and unable to write normal data.

Scheduling task management in Linux

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.