Linux Add Scheduled Tasks

Source: Internet
Author: User

Crond is a command that Linux uses to execute programs on a regular basis. This task Dispatch command is started by default when the operating system is installed. The Crond command periodically checks to see if there is any work to be done and the work will be performed automatically if there is work to be done. You can start and close this service in the following ways:

[[email protected] ~]#/sbin/service crond start
[[email protected] ~]#/sbin/service Crond stop off
stopping Crond: [OK]
[[email protected] ~]#/sbin/service crond start
Starting Crond: [OK]
[[email protected] ~]#/sbin/service crond restart reboot
stopping Crond: [OK]
Starting Crond: [OK]

[[email protected] ~]#/sbin/service Crond Reload Reload Configuration
Reloading Crond: [OK]

The task scheduling under Linux is divided into two categories, system task scheduling and user task scheduling.

System Task Scheduling : The work to be performed by the system periodically, such as writing cache data to hard disk, log cleanup, etc.

In the/etc directory there is a crontab file, this is the System Task Scheduler configuration file.

[email protected] ~]# Cat/etc/crontab

Shell=/bin/bash

Path=/sbin:/bin:/usr/sbin:/usr/bin

Mailto=root

home=/

# for details see Mans 4 Crontabs

# for details see Mans 4 Crontabs

# Example of Job definition:

#.----------------Minute (0-59)

# | .-------------Hour (0-23)

# |  | .----------Day of Month (1-31)

# |  |  | .-------month (1-12) OR jan,feb,mar,apr ...

# |  |  |  | .----Day of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat

# |  |  |  | |

# * * * * * * user-name command to be executed

The first line of the shell variable specifies which shell the system will use, and this is bash

The second line of PATH variable specifies the path of the System execution command

The third line of the mailto variable specifies that Crond's task execution information will be emailed to the root user, and if the value of the mailto variable is null, the task execution information is not sent to the user

The four-row home variable specifies the home directory to use when executing the command or script.

User Task Scheduling : Tasks that users perform on a regular basis, such as user data backup. Users can use the Crontab tool to customize their own scheduled tasks.

All user-defined crontab files are saved in the/var/spool/cron directory. Its file name is the same as the user name.

Linux Add Scheduled Tasks

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.