[20180608]asmcmd显示文件的日期时间问题.txt
http://blog.iarsov.com/oracle/date-and-time-format-in-asmcmd-for-file-listing/
--//如果你使用asmcmd查看asm文件,你可以发现日期时间的显示格式:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
ASMCMD [+data/fyhis/PARAMETERFILE] > ls -l
Type Redund Striped Time Sys Name
PARAMETERFILE UNPROT COARSE JUN 08 00:00:00 Y spfile.272.931438543
--//仅仅显示日期,而时分秒都是0.
ASMCMD [+data/fyhis/ARCHIVELOG/2017_02_09] > ls -ls thread_1_seq_3773.3605.935537807
Type Redund Striped Time Sys Block_Size Blocks Bytes Space Name
ARCHIVELOG UNPROT COARSE FEB 09 2017 Y 512 937 479744 1048576 thread_1_seq_3773.3605.935537807
--//而实际上asmcmd是shell 脚本,最后运行的是perl脚本.
$ file $(which asmcmd)
/u01/app/11.2.0/grid/bin/asmcmd: POSIX shell script text executable
--//链接:http://blog.iarsov.com/oracle/date-and-time-format-in-asmcmd-for-file-listing/
ASMCMD utility base module is asmcmdbase.pm
The subroutine for listing files located in the base module is asmcmdbase_ls_process_file. You can see the logic how
file dates are printed. We can notice that if the file is older than 6 months the format used is "MON DD YYYY". If the
file is newer, the format used is "MON DD HH24:MI:SS". This subroutine is called (executed) for each file that needs to
be printed in ASMCMD.
List entries $entry_info_ref->{'mod_date'} and $entry_info_ref->{'mod_time'} contain the data for both hardcoded
formats. MOD_DATE if the files is older than 6 months and MOD_TIME if the file is newer.
sub asmcmdbase_ls_process_file
{
my ($dbh, $entry_info_ref, $args_ref, $cur_date, $file_info) = @_;
my ($related_alias); # The user or system alias for its corresponding #
# system or user alias, respectively. #
# Calculate dates only if we have file info from v$asm_file.
if ($file_info)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
# Use separate date format if date older than half a year.
if (($cur_date - $entry_info_ref->{'julian_date'}) >= $ASMCMDBASE_SIXMONTH)
{ # If older than six months, use 'MON DD YYYY' format. #
$entry_info_ref->{'date_print'} = $entry_info_ref->{'mod_date'};
}
else
{ # Otherwise, use 'MON DD HH24:MI:SS' format. #
$entry_info_ref->{'date_print'} = $entry_info_ref->{'mod_time'};
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
--//说明:如果旧于6个月,显示日期.use 'MON DD YYYY' format.其他使用use '