Date::Manip 문제로 인해 Logwatch를 실행할 수 없습니다.

Date::Manip 문제로 인해 Logwatch를 실행할 수 없습니다.

다음에서 logwatch를 실행하려고했습니다.

[root@machine cron.daily]# ./0logwatch 
ERROR: Date::Manip unable to determine TimeZone.

Execute the following command in a shell prompt:
        perldoc Date::Manip
The section titled TIMEZONES describes valid TimeZones
and where they can be defined.

내 날짜는 다음과 같습니다

root@machine cron.daily]# date
Thu Aug 23 06:25:21 GMT 2012

이제 다양한 포럼의 세부 사항을 기반으로 설정하여 이 문제를 해결하려고 했습니다.

/etc/timezone to “+0800”

하지만 작동하지 않았다

/etc/localtime포인트가 /usr/share/zoneinfo/GMT 관리되고 있습니다.인형

이 문제를 해결하려면 어떻게 해야 합니까? 나는 여전히 내 모든 컴퓨터가 GMT 시간대에 있기를 원합니다.

편집하다:
안타깝게도
두 가지 변경 사항이 모두 작동하지 않습니다.

[root@machine cron.daily]# cat /etc/TIMEZONE 
UTC

콴타스

[root@machine cron.daily]# cat ~/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export TZ=GMT

export PATH
[root@machine cron.daily]# source ~/.bash_profile
[root@machine cron.daily]# ./0logwatch 
ERROR: Date::Manip unable to determine TimeZone.

Execute the following command in a shell prompt:
        perldoc Date::Manip
The section titled TIMEZONES describes valid TimeZones
and where they can be defined.

답변1

/etc/timezone현재 시간대는 GMT인데 왜 "+0800"으로 설정하셨나요 ?

perldoc Date::Manip

   The following time zone names are currently understood (and can be used in parsing dates).  These are zones
   defined in RFC 822.

       Universal:  GMT, UT
       US zones :  EST, EDT, CST, CDT, MST, MDT, PST, PDT
       Military :  A to Z (except J)
       Other    :  +HHMM or -HHMM
       ISO 8601 :  +HH:MM, +HH, -HH:MM, -HH

   In addition, the following time zone abbreviations are also accepted. These do not come from a standard, but were
   included in previous releases of Date::Manip 5.xx and are preserved here for backward compatibility:

      IDLW    -1200    International Date Line West
      NT      -1100    Nome
      SAT     -0400    Chile
      CLDT    -0300    Chile Daylight
      AT      -0200    Azores
      MEWT    +0100    Middle European Winter
      MEZ     +0100    Middle European
      FWT     +0100    French Winter
      GB      +0100    GMT with daylight savings
      SWT     +0100    Swedish Winter
      MESZ    +0200    Middle European Summer
      FST     +0200    French Summer
      METDST  +0200    An alias for MEST used by HP-UX
      EETDST  +0300    An alias for eest used by HP-UX
      EETEDT  +0300    Eastern Europe, USSR Zone 1
      BT      +0300    Baghdad, USSR Zone 2
      IT      +0330    Iran
      ZP4     +0400    USSR Zone 3
      ZP5     +0500    USSR Zone 4
      IST     +0530    Indian Standard
      ZP6     +0600    USSR Zone 5
      AWST    +0800    Australian Western Standard
      ROK     +0900    Republic of Korea
      AEST    +1000    Australian Eastern Standard
      ACDT    +1030    Australian Central Daylight
      CADT    +1030    Central Australian Daylight
      AEDT    +1100    Australian Eastern Daylight
      EADT    +1100    Eastern Australian Daylight
      NZT     +1200    New Zealand
      IDLE    +1200    International Date Line East

   All other time zone abbreviations come from the standards. In many cases, an abbreviation may be used for multiple
   timezones. For example, NST stands for Newfoundland Standard -0330 and North Sumatra +0630.  In these cases, only
   1 of the two is available. I have tried to use the most recent definition, and of those (if multiple timezones use
   the abbreviation), the most commonly used. I don’t claim that I’m correct in all cases, but I’ve done the best I
   could.

   The list of abbreviations available is documented in the Date::Manip::DM5abbrevs document in this module, or more
   fully in the Date::Manip::Zones document of Date::Manip::6.xx.

   Date::Manip must be able to determine the time zone the user is in.  It does this by looking in the following
   places:

      $Date::Manip::TZ (set with Date_Init or in Manip.pm)
      $ENV{TZ}
      the Unix ‘date‘ command (if available)
      $main::TZ
      /etc/TIMEZONE
      /etc/timezone

   At least one of these should contain a time zone in one of the supported forms.  If none do by default, the TZ
   variable must be set with Date_Init.

   The time zone may be in the STD#DST format (in which case both abbreviations must be in the table above) or any of
   the formats described above.  The STD#DST format is NOT available when parsing a date however.  The following
   forms are also available and are treated similar to the STD#DST forms:

         US/Pacific
         US/Mountain
         US/Central
         US/Eastern
         Canada/Pacific
         Canada/Mountain
         Canada/Central
         Canada/Eastern

어떤 Date::Manip버전을 실행하고 있나요?

어떤 이유로 Perl이 /etc/timezone또는 를 읽지 못하는 경우 /etc/TIMEZONE다음 행을 다음에 추가할 수 있습니다 /root/.bash_profile.

export TZ=GMT

실행하여 즉시 적용되도록 source /root/.bash_profile하고 다시 시도하세요.


업데이트 8월 30일 목요일 10:55:54 ICT 2012

logwatch perl 스크립트에서 시간대를 설정해 보십시오:

use Date::Manip;

Date_Init("TZ=GMT");

답변2

실제로이것은 효과가 있었다

export DATE_MANIP=DM5

답변3

그건 해결책이 아니라 해결 방법입니다. 하지만 그렇게 해야 합니다.

효과가 없었던 이유는TIMEZONE대문자로 표시될 것으로 예상됩니다..

echo UTC > /etc/TIMEZONE

관련 정보