Sponsored Content
Top Forums Shell Programming and Scripting Help needed with date compare Post 302810157 by jakSun8 on Tuesday 21st of May 2013 09:51:41 AM
Old 05-21-2013
Help needed with date compare

Hello,

I have this unix script which selects rows from DB where current time is greater than expired time (column). So this will give all the records that are expired 1 day ago, 2 days ago, 3 days ago, etc.. I need help modifying in such that it should give records that are only expired 1 day ago (24-hour period)

Code:
#-------------------------------------------------------------
# Log into database and execute stored procedure
#-------------------------------------------------------------
sqlplus -S myLogin/myPwd@myServer >> /tmp/myLogFile << EOF
    whenever sqlerror exit 1
    set echo off
    set pagesize 0
    set feedback off
    set trimout on
    set trimspool on
    set heading off
    SPOOL /tmp/myExpiredList
select my_id, my_expr_tmstp from MY_SCHEMA.MY_TABLE where current_timestamp > my_expr_tmstp ;                                                    
SPOOL OFF
EOF

Thanks in advance - jak
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare date from db2 table to yesterday's Unix system date

I am currently running the following Korn shell script which works fine: #!/usr/bin/ksh count=`db2 -x "select count(*) from schema.tablename"` echo "count" I would like to add a "where" clause to the 2nd line that would allow me to get a record count of all the records from schema.tablename... (9 Replies)
Discussion started by: sasaliasim
9 Replies

2. Shell Programming and Scripting

Compare Start date and End date...

Hi All, I have problem in my file. It has two date variable. There are 2 variables which has the values as below 1. START_MONTH = “Date(YYYYMM) format” Ex: 201008 2. END_MONTH = “Date(YYYYMM) format” Ex: 201105 The end date should be greater than start date. Now we... (3 Replies)
Discussion started by: suresh01_apk
3 Replies

3. Shell Programming and Scripting

ksh compare dates INSIDE a file (ie date A is > date B)

In KSH, I am pasting 2 almost identical files together and each one has a date and time on each line. I need to determine if the first instance of the date/time is greater than the 2nd instance of the date/time. If the first instance is greater, I just need to echo that line. I thought I would... (4 Replies)
Discussion started by: right_coaster
4 Replies

4. Shell Programming and Scripting

Adding days to system date then compare to a date

Hi! I am trying to read a file and every line has a specific date as one of its fields. I want to take that date and compare it to the date today plus 6 days. while read line do date=substr($line, $datepos, 8) #date is expected to be YYYYMMDD if ; then ...proceed commands ... (1 Reply)
Discussion started by: kokoro
1 Replies

5. Shell Programming and Scripting

Compare Date with String in date format

Hi, I am new to this forum, searched, but for some reason did not find much help, so a new thread. I am trying to compare date with a string which is in date format , but for some reason, system does not give me the right result. Date is coming in a file and i am comparing the same with... (2 Replies)
Discussion started by: mkstool
2 Replies

6. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

hi all, How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

7. Shell Programming and Scripting

Compare the system date with date from a text file

I get the date that's inside a text file and assigned it to a variable. When I grep the date from the file, I get this, Not After : Jul 28 14:09:57 2017 GMT So I only crop out the date, with this command echo $dateFile | cut -d ':' -f 2,4The result would be Jul 28 14:57 2017 GMT How do I... (3 Replies)
Discussion started by: Loc
3 Replies

8. UNIX for Beginners Questions & Answers

Compare date in .txt with system date and remove if it's lesser than system date

Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt . I don't want to delete... (2 Replies)
Discussion started by: Stuti
2 Replies

9. Answers to Frequently Asked Questions

Compare date in .txt with system date and remove if it's lesser than system date

I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Discussion started by: Stuti
1 Replies

10. UNIX for Beginners Questions & Answers

Compare Date to today's date in shell script

Hi Community! Following on from this code in another thread: #!/bin/bash file_string=`/bin/cat date.txt | /usr/bin/awk '{print $5,$4,$7,$6,$8}'` file_date=`/bin/date -d "$file_string"` file_epoch=`/bin/date -d "$file_string" +%s` now_epoch=`/bin/date +%s` if then #let... (2 Replies)
Discussion started by: Greenage
2 Replies
fmdump(1M)                                                                                                                              fmdump(1M)

NAME
fmdump - fault management log viewer SYNOPSIS
fmdump [-efvV] [-c class] [-R dir] [-t time] [-T time] [-u uid] [file] The fmdump utility can be used to display the contents of any of the log files associated with the Solaris Fault Manager, fmd(1M). The Fault Manager runs in the background on each Solaris system. It receives telemetry information relating to problems detected by the system software, diagnoses these problems, and initiates proactive self-healing activities such as disabling faulty components. The Fault Manager maintains two sets of log files for use by administrators and service personnel: error log A log which records error telemetry, the symptoms of problems detected by the system. fault log A log which records fault diagnosis information, the problems believed to explain these symptoms. By default, fmdump displays the contents of the fault log, which records the result of each diagnosis made by the fault manager or one of its component modules. An example of a default fmdump display follows: # fmdump TIME UUID SUNW-MSG-ID Dec 28 13:01:27.3919 bf36f0ea-9e47-42b5-fc6f-c0d979c4c8f4 FMD-8000-11 Dec 28 13:01:49.3765 3a186292-3402-40ff-b5ae-810601be337d FMD-8000-11 Dec 28 13:02:59.4448 58107381-1985-48a4-b56f-91d8a617ad83 FMD-8000-OW ... Each problem recorded in the fault log is identified by: o The time of its diagnosis o A Universal Unique Identifier (UUID) that can be used to uniquely identify this particular problem across any set of systems o A message identifier that can be used to access a corresponding knowledge article located at Sun's web site, http://www.sun.com/msg/ If a problem requires action by a human administrator or service technician or affects system behavior, the Fault Manager also issues a human-readable message to syslogd(1M). This message provides a summary of the problem and a reference to the knowledge article on the Sun web site, http://www.sun.com/msg/. You can use the -v and -V options to expand the display from a single-line summary to increased levels of detail for each event recorded in the log. The -c, -t, -T, and -u options can be used to filter the output by selecting only those events that match the specified class, range of times, or uuid. If more than one filter option is present on the command-line, the options combine to display only those events that are selected by the logical AND of the options. If more than one instance of the same filter option is present on the command-line, the like options combine to display any events selected by the logical OR of the options. For example, the command: # fmdump -u uuid1 -u uuid2 -t 02Dec03 selects events whose attributes are (uuid1 OR uuid2) AND (time on or after 02Dec03). The following options are supported: -c class Select events that match the specified class. The class argument can use the glob pattern matching syntax described in sh(1). The class represents a hierarchical classification string indicating the type of telemetry event. More information about Sun's telemetry protocol is available at Sun's web site, http://www.sun.com/msg/. -e Display events from the fault management error log instead of the fault log. This option is shorthand for specifying the pathname of the error log file. The error log file contains Private telemetry information used by Sun's automated diagnosis software. This information is recorded to facilitate post-mortem analysis of problems and event replay, and should not be parsed or relied upon for the development of scripts and other tools. See attributes(5) for information about Sun's rules for Private interfaces. -f Follow the growth of the log file by waiting for additional data. fmdump enters an infinite loop where it will sleep for a second, attempt to read and format new data from the log file, and then go back to sleep. This loop can be terminated at any time by sending an interrupt (Control-C). -R dir Use the specified root directory for the log files accessed by fmdump, instead of the default root (/). -t time Select events that occurred at or after the specified time. The time can be specified using any of the following forms: mm/dd/yy hh:mm:ss Month, day, year, hour in 24-hour format, minute, and second. Any amount of whitespace can separate the date and time. The argument should be quoted so that the shell interprets the two strings as a single argument. mm/dd/yy hh:mm Month, day, year, hour in 24-hour format, and minute. Any amount of whitespace can separate the date and time. The argument should be quoted so that the shell interprets the two strings as a single argument. mm/dd/yy 12:00:00AM on the specified month, day, and year. ddMonyy hh:mm:ss Day, month name, year, hour in 24-hour format, minute, and second. Any amount of whitespace can separate the date and time. The argument should be quoted so that the shell interprets the two strings as a single argument. ddMonyy hh:mm Day, month name, year, hour in 24-hour format, and minute. Any amount of whitespace can separate the date and time. The argument should be quoted so that the shell interprets the two strings as a single argument. Mon dd hh:mm:ss Month, day, hour in 24-hour format, minute, and second of the current year. yyyy-mm-dd [T hh:mm[:ss]] Year, month, day, and optional hour in 24-hour format, minute, and second. The second, or hour, minute, and second, can be optionally omitted. ddMonyy 12:00:00AM on the specified day, month name, and year. hh:mm:ss Hour in 24-hour format, minute, and second of the current day. hh:mm Hour in 24-hour format and minute of the current day. Tns | Tnsec T nanoseconds ago where T is an integer value specified in base 10. Tus |Tusec T microseconds ago where T is an integer value specified in base 10. Tms | Tmsec T milliseconds ago where T is an integer value specified in base 10. Ts | Tsec T seconds ago where T is an integer value specified in base 10. Tm |Tmin T minutes ago where T is an integer value specified in base 10. Th |Thour T hours ago where T is an integer value specified in base 10. Td |Tday T days ago where T is an integer value specified in base 10. You can append a decimal fraction of the form .n to any -t option argument to indicate a fractional number of seconds beyond the specified time. -T time Select events that occurred at or before the specified time. time can be specified using any of the time formats described for the -t option. -u uuid Select fault diagnosis events that exactly match the specified uuid. Each diagnosis is associated with a Universal Unique Identifier (UUID) for identification purposes. The -u option can be combined with other options such as -v to show all of the details associated with a particular diagnosis. If the -e option and -u option are both present, the error events that are cross-referenced by the specified diagnosis are displayed. -v Display verbose event detail. The event display is enlarged to show additional common members of the selected events. -V Display very verbose event detail. The event display is enlarged to show every member of the name-value pair list associ- ated with each event. In addition, for fault logs, the event display includes a list of cross-references to the correspond- ing errors that were associated with the diagnosis. The following operands are supported: file Specifies an alternate log file to display instead of the system fault log. The fmdump utility determines the type of the specified log automatically and produces appropriate output for the selected log. The following exit values are returned: 0 Successful completion. All records in the log file were examined successfully. 1 A fatal error occurred. This prevented any log file data from being examined, such as failure to open the specified file. 2 Invalid command-line options were specified. 3 The log file was opened successfully, but one or more log file records were not displayed, either due to an I/O error or because the records themselves were malformed. fmdump issues a warning message for each record that could not be displayed, and then con- tinues on and attempts to display other records. /var/fm/fmd Fault management log directory See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWfmd | +-----------------------------+-----------------------------+ |Interface Stability |See below. | +-----------------------------+-----------------------------+ The command-line options are Evolving. The human-readable error log output is Private. The human-readable fault log output is Evolving. sh(1), fmadm(1M), fmd(1M), fmstat(1M), syslogd(1M), libexacct(3LIB), attributes(5) http://www.sun.com/msg/ Fault logs contain references to records stored in error logs that can be displayed using fmdump -V to understand the errors that were used in the diagnosis of a particular fault. These links are preserved if an error log is renamed as part of log rotation. They can be broken by removing or copying an error log file, or by moving the error log to a different filesystem. fmdump can not display error information for such broken links. It continues to display any and all information present in the fault log. 9 Mar 2005 fmdump(1M)
All times are GMT -4. The time now is 02:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy