在尝试安装Perl Power Tools后,我在RHEL 5.3中遇到问题。 一切工作正常,直到我尝试手动安装该软件包(服务器无法访问Internet)。
起初,每个使用awk的shell脚本都给出了错误,因此我删除了Perl Power Tools,并从服务器中configuration的本地存储库中重新安装了awk,并解决了该问题。 之后,cron作业开始给出命令date的错误。
当我执行“男人约会”时,
DATE(1) User Contributed Perl Documentation DATE(1) Name: date Description: display or set date and time Author: Joshua Gross License: NAME date - display or set date and time perl v5.8.8 2014-12-18 DATE(1) (END)
但是默认的date命令应该给这个其他的输出:
DATE(1) User Commands DATE(1) NAME date - print or set the system date and time SYNOPSIS date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] DESCRIPTION Display the current time in the given FORMAT, or set the system date. -d, --date=STRING display time described by STRING, not 'now' -f, --file=DATEFILE like --date once for each line of DATEFILE -r, --reference=FILE display the last modification time of FILE -R, --rfc-2822 output date and time in RFC 2822 format --rfc-3339=TIMESPEC output date and time in RFC 3339 format. TIMESPEC='date', 'seconds', or 'ns' for date and time to the indicated precision. -s, --set=STRING set time described by STRING -u, --utc, --universal print or set Coordinated Universal Time --help display this help and exit
我试图卸载date并重新安装coreutils(包含date的软件包),但由于某种原因,新的date命令不断回来。 我不知道如何恢复旧的date命令。 提前致谢。
干杯,
UPDATE1:
这就是在脚本内部如何使用date以及它产生的错误:
date --date="1 days ago" +%Y%m Option -date not support in this version.
当我用默认的date命令尝试在另一台服务器,它运行良好。
这是哪个date的输出:
[root@wrongserver ~]# which date /bin/date
更新2:
date的输出 – 正常服务器的版本:
[root@OKserver lib64]$ date --version date (GNU coreutils) 5.97 Copyright (C) 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. Written by David MacKenzie.
date输出 – 有问题的服务器中的版本:
[root@wrongserver ~]# date --version date (GNU coreutils) 5.97 Copyright (C) 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. Written by David MacKenzie.
看起来像重新安装后没有改变的唯一的东西是手册页,我实际上使用相同的date二进制文件,date也来自正确的包
[root@domstats ~]# rpm -qf /bin/date coreutils-5.97-19.el5
但是当我在使用crontab的脚本中运行date命令时,我仍然遇到错误,我想我以前没有这么说过。 date命令的错误是在行date --date="1 days ago" +%Y%m在crontab脚本中运行的。 如果我在提示符下运行,它会很好,如果我手动运行脚本也可以。
我做了一些testing,并改变了这样的顺序,使脚本正常运行与cron date +%Y%m --date="1 days ago" ,当然,改变这在我在cron中的脚本是一个痛苦,它应该正常工作,因为在其他服务器上工作。
好吧,我发现了这个小错误,我知道这是一个足够小的东西,不被注意到。 事实certificate,当cron中的脚本运行时,PATHvariables正在被改变,最终如此/usr/bin:/bin 。
冲突的date命令安装在/ usr / bin中,而不是在/ bin中,所以cron使用了错误的命令,我不能注意到,因为在正常的用户会话中,PATHvariables被颠倒/bin:/usr/bin 。
感谢您的帮助,但。