Sponsored Content
Top Forums Shell Programming and Scripting How to extract log data based on current date and month ? Post 302452826 by superHonda123 on Monday 13th of September 2010 07:30:18 AM
Old 09-13-2010
Question How to extract log data based on current date and month ?

Hi Gurus,

I'm using HP-UX B.11.23 operating system.

I've been trying to extract this log info based on the current date and month, but was having some issues as the date column which on the 4th column has a comma and the 5th column has a dot tied to it.

Here is the output from my shut down log info.

Code:
cat /etc/shutdownlog | tail -10

13:36  Sun Dec 8, 2009.  Reboot:  (by root)
13:56  Sun Dec 10, 2009.  Halt:  (by root)
15:12  Sun Dec 27, 2009.  Reboot:  (by root)
13:46  Sun Apr 1, 2010.  Halt:
14:43  Sun Apr 8, 2010.  Halt:
17:28  Sun Apr 18, 2010.  Reboot:  (by root)
18:15  Thu Jul  1, 2010.  Reboot:  (by  root)
12:01  Mon Aug 30, 2010.  Reboot:  (by root)

Previously, I got some help some Gurus in this forum to use this type of AWK as a function module. Please see below.

AWKDATEMTH() {
awk -v v1=`date +'%h'` -v v2=`date +'%d'` -v v3=`awk '{print $4}' | tr -d ','` '$3==v1 && v3==v2'}

However, I've been trying to fix it to cater for my new log data, but was to no luck. Guess my scripting level is limited.

Appreciate for any of your help and advice.

Thank you in advance.

Cheers.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the create time of a file if current date is in next month

Hi All, I want to find the time diffrence between currnt time and "abc.txt" file create time. I have solve that but if the abc.txt file created last month then is there any process to find the difftent? Exp: Create time of abc.txt is "Apr 14 06:48" and currect date is "May 17 23:47".... (1 Reply)
Discussion started by: priyankak
1 Replies

2. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

3. Shell Programming and Scripting

How to extract log data based on date

Hi Gurus, I've been having some problem in extracting the log data based on the current date and month. As shown in the sample data below, how to extract the log info for Aug 11? Sample data: root pts/ta userpc Wed Aug 11 09:46 - 20:21 (10:35) root pts/ta userpc... (13 Replies)
Discussion started by: superHonda123
13 Replies

4. Shell Programming and Scripting

How to extract log info based on last month?

Hi Gurus I'm using HPUX B.11.23 ia64, the below sample log data was extracted from HPUX commnad: last -R. Sample data: root pts/ta userpc Wed Aug 11 09:46 - 20:21 (10:35) root pts/ta userpc Wed Aug 11 09:44 - 20:10 (10:34) root pts/ta userpc Wed Aug 11... (4 Replies)
Discussion started by: superHonda123
4 Replies

5. Shell Programming and Scripting

current date - one month in AIX

Hi, i unable to get the last month date in AIX. current date - one month Based on the forums tried but did not find the relevent information. Any help grealy appriciated. Thanks Suri. (3 Replies)
Discussion started by: onesuri
3 Replies

6. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

7. UNIX for Dummies Questions & Answers

Extract date ranged data from log file

Hi, I am trying to extract lines of data within a log file on a Redhat 5 Linux system. eg I need all the lines with a particular username over the last 3 minutes. the log file may read like this, and I want a way to search all the lines extracting all the relevant lines over the last 3... (2 Replies)
Discussion started by: mantis100
2 Replies

8. AIX

AIX - Get next month from current date

As said in object, how can i obtain that? In linux i use date -d "1 month" +"%m%Y". Thanks i advance. (8 Replies)
Discussion started by: fabfisc
8 Replies

9. Homework & Coursework Questions

How to minus 2 month from current date?

I am running a script in ksh to get the 2 months back date from system date.The below code is giving correct date output from putty command prompt.But while running the script is .ksh file it is giving the error below.Please suggest. ; d=a; y=a m-=num while(m < 1) {m+=12; y--}... (1 Reply)
Discussion started by: hini
1 Replies

10. UNIX for Beginners Questions & Answers

How to get first & last day of a month from current date?

Hi, I need the first & last day of a month from any given date. For better understanding, if i need to back-fill data for date 07/20/2019 i.e July 20 2019, i need the first & last day has 07/01/2019 - 07/31/2019. FYI: I'm using GIT BASH terminal. sample code: export DT=$(date --date='6 days... (2 Replies)
Discussion started by: Rocky975583
2 Replies
uadmin(2)																 uadmin(2)

NAME
uadmin - administrative control SYNOPSIS
#include <sys/uadmin.h> int uadmin(int cmd, int fcn, uintptr_t mdep); The uadmin() function provides control for basic administrative functions. This function is tightly coupled to the system administrative procedures and is not intended for general use. The argument mdep is provided for machine-dependent use and is not defined here. As specified by cmd, the following commands are available: A_SHUTDOWN The system is shut down. All user processes are killed, the buffer cache is flushed, and the root file system is unmounted. The action to be taken after the system has been shut down is specified by fcn. The functions are generic; the hardware capabilities vary on specific machines. AD_HALT Halt the processor(s). AD_POWEROFF Halt the processor(s) and turn off the power. AD_BOOT Reboot the system, using the kernel file. AD_IBOOT Interactive reboot; user is prompted for bootable program name. A_REBOOT The system stops immediately without any further processing. The action to be taken next is specified by fcn as above. A_DUMP The system is forced to panic immediately without any further processing and a crash dump is written to the dump device (see dumpadm(1M)). The action to be taken next is specified by fcn, as above. A_REMOUNT The root file system is mounted again after having been fixed. This should be used only during the startup process. A_FREEZE Suspend the whole system. The system state is preserved in the state file. The following subcommands, specified by fcn, are available. AD_COMPRESS Save the system state to the state file with compression of data. AD_CHECK Check if your system supports suspend and resume. Without performing a system suspend/resume, this com- mand checks if this feature is currently available on your system. AD_FORCE Force AD_COMPRESS even when threads of user applications are not suspendable. Upon successful completion, the value returned depends on cmd as follows: A_SHUTDOWN Never returns. A_REBOOT Never returns. A_FREEZE 0 upon resume. A_REMOUNT 0. Otherwise, -1 is returned and errno is set to indicate the error. The uadmin() function will fail if: EBUSY Suspend is already in progress. EINVAL The cmd argument is invalid. ENOMEM Suspend/resume ran out of physical memory. ENOSPC Suspend/resume could not allocate enough space on the root file system to store system information. ENOTSUP Suspend/resume is not supported on this platform or the command specified by cmd is not allowed. ENXIO Unable to successfully suspend system. EPERM The {PRIV_SYS_CONFIG} privilege is not asserted in the effective set of the calling process. dumpadm(1M), kernel(1M), uadmin(1M), privileges(5) 1 Sep 2005 uadmin(2)
All times are GMT -4. The time now is 10:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy