• RHEL7学习之crontab无法执行ntpdate


    1,"/etc/crontab"文件

    [root@localhost ~]# more /etc/crontab
    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    
    # For details see man 4 crontabs
    
    # 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

    2,检查crond服务是否启动,crontab命令格式后,还是无法同步。查看crontab日志

    From root@localhost.localdomain  Sat Feb 13 00:43:01 2010
    Return-Path: <root@localhost.localdomain>
    X-Original-To: root
    Delivered-To: root@localhost.localdomain
    Received: by localhost.localdomain (Postfix, from userid 0)
        id B340060ADA00; Sat, 13 Feb 2010 00:43:01 +0800 (CST)
    From: "(Cron Daemon)" <root@localhost.localdomain>
    To: root@localhost.localdomain
    Subject: Cron <root@localhost> root ntpdate -u  192.168.10.10
    Content-Type: text/plain; charset=UTF-8
    Auto-Submitted: auto-generated
    Precedence: bulk
    X-Cron-Env: <XDG_SESSION_ID=68>
    X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
    X-Cron-Env: <LANG=en_US.UTF-8>
    X-Cron-Env: <SHELL=/bin/sh>
    X-Cron-Env: <HOME=/root>
    X-Cron-Env: <PATH=/usr/bin:/bin>
    X-Cron-Env: <LOGNAME=root>
    X-Cron-Env: <USER=root>
    Message-Id: <20100212164301.B340060ADA00@localhost.localdomain>
    Date: Sat, 13 Feb 2010 00:43:01 +0800 (CST)
    
    /bin/sh: root: command not found

    3,发现"/bin/sh: root: command not found",需要改成绝对路径

    [root@localhost ~]# whereis crontab
    crontab: /usr/bin/crontab /etc/crontab /usr/share/man/man1/crontab.1.gz /usr/share/man/man5/crontab.5.gz
    [root@localhost ~]# whereis clock
    clock: /usr/sbin/clock /usr/share/man/man8/clock.8.gz
    [root@localhost ~]# crontab -e
    
    30 3 * * *  /usr/sbin/ntpdate -u  192.168.10.10; /usr/sbin/clock -w 
  • 相关阅读:
    Python爬虫之记录一次下载验证码的尝试
    Python之学会测试,让开发更加高效(一)
    NLP(二十八)多标签文本分类
    NLP(二十七)开放领域的三元组抽取的一次尝试
    NLP(二十六)限定领域的三元组抽取的一次尝试
    Numpy之数据保存与读取
    TortoiseGit的首次使用
    NLP(二十五)实现ALBERT+Bi-LSTM+CRF模型
    NLP(二十四)利用ALBERT实现命名实体识别
    NLP(二十三)序列标注算法评估模块seqeval的使用
  • 原文地址:https://www.cnblogs.com/fishhh/p/5202559.html
Copyright © 2020-2023  润新知