1

I'm having a problem in a RHEL 5.3 after I tried installing Perl Power Tools. Everything was working fine until I tried installing that package by hand (the server has no access to internet).

At first every shell script that used awk was giving errors so I removed Perl Power Tools and reinstalled awk from a local repository that is configured in the server and that problem was solved. After that cron jobs started to give errors with the command date.

When I perform a "man date" this is comming out:

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)

But the default date command should give this other output:

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 

I tried uninstalling date and reinstalling coreutils (the package that contains date) but for some reason the new date command keeps comming back. I don't know how to restore the old date command. Thanks in advance.

Cheers,

UPDATE1:

This is how date is being used inside the scripts and the error it produces:

date --date="1 days ago" +%Y%m
Option -date not support in this version.

When I try that in another server with the default date command it runs fine.

This is the output of which date:

[root@wrongserver ~]# which date
/bin/date

UPDATE 2:

Output of date --version in normal server:

[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.

Output of date --version in problematic server:

[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.

Seems like the only thing that didn't changed after reinstallation was the man page and I'm actually using the same date binaries, also the date is comming from the right package

[root@domstats ~]# rpm -qf /bin/date
coreutils-5.97-19.el5

But I'm still getting the errors when I run the date command in scripts using crontab, I think I didn't remarked that enough before. The error with the date command comes ONLY when the line date --date="1 days ago" +%Y%m is run in a script with crontab. If I run the line in the prompt it goes fine, If I run the script by hand it also works.

I made some tests and changing the order like this make the scripts run normally with cron date +%Y%m --date="1 days ago", of course, changing this in the scripts I have in cron is a pain and it should work normally since in the other server does work.

2
  • What happens if you actually call date and not the manual page with man date? Also, what's the output of which date?
    – Sven
    Apr 6, 2015 at 16:40
  • Compare output of date --version on the two systems. Also, to verify where your date command is coming from run rpm -qf /bin/date on both machines.
    – Joe
    Apr 6, 2015 at 17:37

1 Answer 1

1

Ok, I found this little bug, I knew it was something small enough to not be noticed. It turns out the PATH variable was being changed when the scripts in cron were ran and ended up like this /usr/bin:/bin.

The conflicting date command was installed in /usr/bin and not in /bin so cron was using the wrong one and I couldn't notice because in the normal user session the PATH variable was reversed /bin:/usr/bin.

Thanks for the help though.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .