RHEL7学习之crontab无法执行ntpdate
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RHEL7学习之crontab无法执行ntpdate相关的知识,希望对你有一定的参考价值。
1,"/etc/crontab"文件
[[email protected] ~]# 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 [email protected] Sat Feb 13 00:43:01 2010 Return-Path: <[email protected]> X-Original-To: root Delivered-To: [email protected] Received: by localhost.localdomain (Postfix, from userid 0) id B340060ADA00; Sat, 13 Feb 2010 00:43:01 +0800 (CST) From: "(Cron Daemon)" <[email protected]> To: [email protected] Subject: Cron <[email protected]> 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[email protected]> Date: Sat, 13 Feb 2010 00:43:01 +0800 (CST) /bin/sh: root: command not found
3,发现"/bin/sh: root: command not found",需要改成绝对路径
[[email protected] ~]# whereis crontab crontab: /usr/bin/crontab /etc/crontab /usr/share/man/man1/crontab.1.gz /usr/share/man/man5/crontab.5.gz [[email protected] ~]# whereis clock clock: /usr/sbin/clock /usr/share/man/man8/clock.8.gz
[[email protected] ~]# crontab -e 30 3 * * * /usr/sbin/ntpdate -u 192.168.10.10; /usr/sbin/clock -w
以上是关于RHEL7学习之crontab无法执行ntpdate的主要内容,如果未能解决你的问题,请参考以下文章