美文网首页
crontab系统定时任务

crontab系统定时任务

作者: code_nerd | 来源:发表于2017-10-27 10:45 被阅读0次

启动

centos 7 systemctl start crond
centos 6 service crond start

用户的crontab设置

命令 crontab [选项]

  • -e 编辑crontab任务
  • -l 查询crontab任务
  • -r 删除当前用户的所有crontab

编辑

crontab -e 进入编辑页面
格式 * * * * * command

  • 一个小时中的第几分钟 [0-59]
  • 一天当中的第几个小时 [0-23]
  • 一个月中的第几天 [1-31]
  • 一年中的第几月 [1-12]
  • 一周当中的星期几[0-7] 0和7都代表星期天

符号含义

符号 含义
* 代表任何时间,比如第一个* 代表每分钟
, 代表不连续的时间,如* 0,8,12,16 * * * command 代表每天的0点,8点12点16点执行命令
- 代表连续的时间范围,如0 5 * * 1-5 command 表示 每周一到周五 五点执行
*/10 代表每隔多久执行一次

列子

命令 含义
45 22 * * * command 在22点45分执行命令
0 5 1,15 * * command 在每月1 号和15号 5点执行命令
0 17 * * 1 command 在星期一17点执行命令
40 4 * * 1-5 command 工作日 4点40分执行命令
*/10 4 * * * command 每天的4点 每隔十分钟执行一次命令
0 0 1,5 * 1 command 每月1号15号 每周一 0点执行command,3 和5 最好不用同时设置
//date 函数输出需要的信息
[root@bogon tmp]# date +%y%m%d
170923
//在crontab 中 需要将%转义,因为crontab中% 有自身的含义
date +\%y\%m\%d

相关文章

  • 定时任务

    目录一:系统定时任务二:系统定时任务配置文件(crontab)三:增加定时任务1.crontab -e2.1.sh...

  • crontab定时任务

    使用crontab部署定时任务 什么是Crontab?Crontab命令是Unix系统和类Unix系统中,用来设置...

  • crondtab 定时任务

    编辑定时任务 crontab -e 查看定时任务 crontab -l 删除定时任务 crontab -r 如:*...

  • crontab的基本使用

    作用 crontab是linux的一项系统服务。用来在linux上面定时执行任务。crontab服务又分为系统任务...

  • linux crontab: 定时任务

    参考 crontab 定时任务 Linux之crontab定时任务

  • Linux定时任务(1)— crontab

    执行定时任务 crontab 执行循环任务 at 执行一次性任务 crontab简介 Linux 系统有个 c...

  • crond任务调度(定时任务调度)

    基本语法crontab [选项]选项-e : 编辑crontab定时任务-l : 查询crontab定时任务...

  • 系统定时任务运行时间与设置的不同

    设置系统定时任务crontab -e查看系统定时任务日志vim /var/log/cron注意 日志是切片的可以...

  • AnolisOS 8 Crontab定时任务

    一、crontab介绍 Crontab是系统定时任务计划,也称之为系统作业,用于周期性的执行程序。crontab定...

  • 定时任务备份运维

    crontab定时任务实现定时备份 linux系统下,定时备份主要需要用到的命令是crontab,还有就是需要能够...

网友评论

      本文标题:crontab系统定时任务

      本文链接:https://www.haomeiwen.com/subject/lkdrpxtx.html