zoukankan      html  css  js  c++  java
  • linux centos 7 定时任务

    一.安装 crontabs服务并设置开机自启:

    yum install crontabs
    systemctl enable crond
    systemctl start crond123

    二.设置用户自定义定时任务:

    vi /etc/crontab

    可以看到:

    # 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

    即:

    分钟(0-59) 小时(0-23) 日(1-31) 月(11-12) 星期(0-6,0表示周日) 用户名 要执行的命令1
    每隔30分钟root执行一次updatedb命令:

    */30 * * * * root updatedb1

    每天早上5点定时重启系统:

    0 5 * * * root reboot1

    三.保存生效:

    #加载任务,使之生效crontab /etc/crontab#查看任务crontab -l

  • 相关阅读:
    IDE-常用插件
    Go-竞态条件-锁
    Go-发送邮件
    复刻网络Yum源配置为本地Yum源使用
    测试
    九.查找算法
    九.多线程-PDF笔记
    八.设计模式
    八.排序算法:复杂度
    七.注解
  • 原文地址:https://www.cnblogs.com/mmmzh/p/10077254.html
Copyright © 2011-2022 走看看