CentOS uses crontab to perform scheduled tasks

Source: Internet
Author: User

Walker's requirement is to execute a shell script at 1 o'clock every day, following the basic features that Walker uses.

1. Installation

Yum Install Crontabs

2. Service-related

/sbin/service crond status #查看任务状态/sbin/service crond start #启动服务/sbin/service crond stop #关闭服务/sbin/ Service Crond Restart #重启服务/sbin/service crond Reload #重新载入配置

3 . View Scheduled Tasks. Basic command line parameters are recommended to use crontab--help , mancrontab too cumbersome.

Crontab-l #查看当前用户计划任务crontab-U userx-l #查看userx用户的计划任务

4 . View the task execution log.

Tail-f/var/log/cron

5,/etc/crontab file inside the system planning tasks,/var/spool/cron/directory inside according to the user to store scheduled tasks.

6. Edit the/etc/crontab Configuration Schedule task.

Shell=/bin/bashpath=/sbin:/bin:/usr/sbin:/usr/binmailto=roothome=/# for details see man  4 crontabs# example of job definition:#&nbsp.---------------- minute   (0 - 59) # |  .------------- hour  (0 - 23) # |   | &NBSP:---------- day of month  (1 - 31) # |  |   | &NBSP:------- month  (1 - 12)  or jan,feb,mar,apr ...# |   |  |  | &NBSP---- day of week  (0 - 6)   (sunday=0 or 7)  or sun,mon,tue,wed,thu,fri,sat# |  |  |   |  |# *  *  *  *  * [user-name]  command to be executed  0  1  *  *  *   root /home/walker/test.sh 

The content format of the scheduled task file in the/var/spool/cron/directory is identical to the above. The difference is that/var/spool/cron/must specify the user;/etc/crontab is a system scheduled task that can be specified without a user.


Walker * * *


This article is from "Walker's Journal" blog, please be sure to keep this source http://walkerqt.blog.51cto.com/1310630/1690113

CentOS uses crontab to perform scheduled tasks

Related Article

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.