Linux's Scheduled Tasks

Source: Internet
Author: User
Tags root access

1 at: One-time task configuration, its tasks can only be performed at the specified times, provided that the ATD service is turned on.

[Email protected] ~]# at 17:45 2017-05-30 #设置任务

at> ls/> A.txt

At> <EOT>

Job 3 at 2017-05-30 17:45


[Email protected] ~]# ATQ #查看一次性任务

32017-05-30 17:45 a root


[Email protected] ~]# ATRM 3 #删除任务


2 crontab: Periodic task configuration, which greatly reduces the operation of repetitive system management tasks. The corresponding system service is crond.

2.1 crontab Configuration files and directories

/etc/crontab--System task profile, system installation automatically set, not recommended modification. The shell environment, executable path, and other variable operations are set in the file.

The configuration file for the/var/spool/cron/--user scheduled task is stored in the directory with the same file name as the user.

[Email protected] cron]# ls-l/var/spool/cron/*

-RW-------. 1 root root Apr 17:28/var/spool/cron/zwj


2.2 Creating and managing scheduled Tasks using Crontab

Options:-e Edit Scheduled Task list

-u specifies which user the task plan belongs to, usually the root user to edit, delete other users ' scheduled tasks

-L Display Scheduled Tasks list

-R Delete Scheduled Task list

[Email protected] cron]# crontab-e-u zwj #为用户zwj建立任务计划

*/2 * * * */bin/ls/>/home/zwj/a.txt


[Email protected] cron]# crontab-l-u zwj #查看用户zwj的任务计划

[Email protected] cron]# crontab-l #查看当前用户的任务计划

No crontab for Root


[Email protected] cron]# crontab-r #清除当前用户的所有计划任务

[[email protected] cron]# crontab-l-U zwj #清除zwj的计划任务, root access required

Attached: example of the format of a scheduled task

Basic format:
* * * * * command
Time-sharing Weekly command

-: Indicates a continuous time range, such as "1-4", indicating 1,2,3,4

,: Indicates a discontinuous range, such as "1,5,8"

/: Represents the interval frequency, such as "*/3" in the date segment, that represents every 3 days.

7 * * */sbin/service sshd start #每天7:30 Start sshd Service

0 0 */5 * */bin/rm-rf/var/ftp/pub/* #每隔5天清空ftp公共目录

0 1 5,15 * */sbin/service httpd restart #每月5号和15号1点重启httpd服务

0 1 5-15 * */bin/rm-rf/var/ftp/pub/* #每月5到15号1点清空ftp公共目录

0 1 * * 6,7/script/a.sh #每周六, Day 1 o'clock in the morning execute script

0 1-7/1 * * */script/a.sh #每天1点到7点之间, scripts executed every 1 hours


This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1917134

Linux's 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.