linux-Scheduled Tasks

Source: Internet
Author: User

Scheduled Tasks
One-time Scheduled tasks
Cyclic Scheduled Tasks

一次性的计划任务安装软件:    #yum install at  -y启动服务:    # systemctl start atd.service    # systemctl status atd.service    # systemctl enable atd.service创建计划任务:    # at 11:00    at> rm -rf  /tmp/*    at> <EOT>            //ctrl+d    job 1 at Fri Dec 15 11:00:00 2017查看:    # at -l    2   Fri Dec 15 11:05:00 2017 a root    # cat /var/spool/at/a000030180daa8删除计划任务:    方式1        # at -r 3         -r 工作号    //删除  3是工作号    方式2        # atrm  3    方式3        直接删除文件at后面各种时间写法:    #man at

Cyclic planning tasks:
User Level
System level

Installing the Software

Yum-y Install Crontabs

Start the service
RHEL5/6:

/etc/init.d/crond status
# /etc/init.d/crond startrhel7:# systemctl start crond.service# systemctl status crond.service# systemctl enable crond.service开机启动(rhel5/6)    #chkconfig crond on

Create a scheduled Task: User-level Scheduled Tasks
#crontab-u user-E
-u specifies that the user does not write by default or root

#crontab-E
Configuration divided into two parts with a space
The first part: Time
Minutes, hours, weeks.
Range 0-59 0-23 1-31 1-12 0-7
The above time range can be viewed in the man Manual: #man 5 crontab

Various time notation:
5 Ten
5 8

1 5 7
5
1,5,9
8-12
5-20,40
8-12,20-25
/5 *

PS: * denotes every ...
, take different points of time

    • Representation Range
      */5 every 5 minutes

Part II: Action
Write the commands you want to execute at the time specified here, of course including scripts (most commonly used), and commands are best to write absolute paths

View Scheduled tasks: two methods
1) #crontab-L
-u user name view scheduled tasks for an account
2) #cat/var/spool/cron/root

Scheduled Task removal: two methods
1) # crontab-r-U Wing
-R Delete
-U Specify user
#crontab-e-U Tom
2) # Rm-f/var/spool/cron/root

Permission Control for Scheduled tasks
#cat/etc/cron.deny
If this file exists, any account written to this file does not allow the crontab command to be executed.
#cat/etc/cron.allow
If this file exists, the account not written to this file does not allow the crontab command to be executed.
If there is an allow file, it is allowed only by the user in the allows file, regardless of whether deny exists

At also has permission control (use as crontab,/etc/at.allow/etc/at.deny)

系统级别的计划任务:# ls /etc/croncron.daily/   cron.hourly/  cron.d/          cron.monthly/ cron.weekly/# cat /etc/anacron

linux-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.