awk statement to find events from a specific date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk statement to find events from a specific date
# 1  
Old 06-25-2010
awk statement to find events from a specific date

I have a script which archives log file events which are 90-days old. Script works fine but I wanted some input on one aspect of this script. My nawk statement, bolded below, that removes events 90-days prior from today, I need it to find anything 90-days or older. The log file date pattern looks like this 03-29-2010
Code:
#!/bin/sh
LOG=tool.log
# Script will compress and archive tool log files older than 90-days
# Perl script to identify the date 90 days prior from today
  date=`perl <<'EOF'
  @T=localtime(time-86400 * 89);printf("%02d-%02d-%02d\n",$T[4]+1,$T[3],$T[5]+1900);
  EOF`
# Next statement will add logs 90-days old in command_archive.gz file
  nawk 'BEGIN {FS="\n"}{RS="#"}{ORS="#"}{if ($2 ~ /^'$date'/) print $0;}' $LOG > archive.temp
  gzip -c archive.temp >> command_archive.gz
# Next statement will remove logs 90-days old from the tool.log file
  nawk 'BEGIN {FS="\n"}{RS="#"}{ORS="#"}{if ($2 !~ /^'$date'/) print $0;}' $LOG > tmp_tool.log
  cp tmp_tool.log $LOG

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To find files having filename containing specific date format

Hi, I have a requirement to create a shell script(tcsh) that finds all the files in a directory having the file name containing date format "YYYYMMDDHHMM" and extract the date time part ""YYYYMMDDHHMM" for further processing. Could you please have any idea on this. trades_201604040000.out... (6 Replies)
Discussion started by: gopal.biswal
6 Replies

2. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

3. UNIX for Dummies Questions & Answers

Find Commands Run on Specific Date

Hello All, I was wondering if anyone knew of a way to find out what commands were run on a specific date. I'm looking to see if I can find certain commands that were run on 3/4, today is 3/10...? Any thoughts or ideas would be much appreciated! Thanks in Advance, Matt ----------... (3 Replies)
Discussion started by: mrm5102
3 Replies

4. Shell Programming and Scripting

Find files for a specific date

Hi, I am looking to find files of a specific date. I am on Sun Solaris so newermt doesnot work.. I thought of using mtime but not getting how to use it. Please help me with this.. Regards Abhinav (3 Replies)
Discussion started by: abhi1988sri
3 Replies

5. Shell Programming and Scripting

Find files with specific date

Dear all, kindly i have some files with different dates i need to grep word from these files but i need to search in files with date 2012-12-02 not all files in this directory do u have any command (4 Replies)
Discussion started by: maxim42
4 Replies

6. Shell Programming and Scripting

Find and print specific date with awk

hi all I would like to help me find the problem with this script to find and print to the screen a specific date of a log file that I have on my server, the date it is received as the first argument in the script $ 1 Here I show you a few lines that made ​​the idea of ​​my log file: ****... (4 Replies)
Discussion started by: gilmore666
4 Replies

7. Shell Programming and Scripting

find command to filter specific type of files older than certain date.

Hi I need to find the list of files in a directory and to do some specific operations based on the type of files. suppose in a directory am having .dat , .log, .err, .rej file types. i need to filter out .dat and .log only which are older than six months. i used the below query but the... (2 Replies)
Discussion started by: msathees
2 Replies

8. Shell Programming and Scripting

help with awk statement and date formatting

I am trying to write a script that will execute one awk statement if the day is Monday and another awk statement for any other day of the week. below is my code. I keep getting "invalid date". I know this is something simple but i can't determine exactly what it is. Please help. if then ... (2 Replies)
Discussion started by: bds052189
2 Replies

9. Shell Programming and Scripting

Getting a specific date from cal output with AWK

Hi guys! I'll make this short... Is there any good way to get the day number that first matches the Monday column from the cal command output with awk (or any other text manipulator commands) ? I'm sorry if my question wasn't clear at all. For example... One cal output would be $... (6 Replies)
Discussion started by: Casey
6 Replies

10. AIX

find files with specific date and time

Hi, I wanna to find files with specific date and time. I know this command: ls -ltr /system1/*.505 | grep 'Jan 18 09:00'. I want the 'Jan 18 09:00' not hard coded, I want it coming from the system date and time. And I want the time varies from 09:00-09:05. Is this possible without heavy... (3 Replies)
Discussion started by: itik
3 Replies
Login or Register to Ask a Question
vzeventd(8)							    Containers							       vzeventd(8)

NAME
vzeventd - the OpenVZ events daemon. SYNOPSIS
vzeventd [-v] [-d] vzeventd -h DESCRIPTION
This daemon takes care of events sent by the OpenVZ kernel (via a netlink socket) and performs required actions associated with those events, by running specific scripts. Every event received contains a container ID, which is passed to the script as VEID environment vari- able. Current list of known events and associated vzeventd actions are: start Ignore. stop Run /usr/lib/vzctl/scripts/vzevent-stop. This script takes care of removing ARP and routing records for the given CT from CT0. mount Ignore. umount Ignore. reboot Run /usr/lib/vzctl/scripts/vzevent-reboot. This script takes care of rebooting a given CT. OPTIONS
-v Increase verbosity (can be used multiple times). -d Debug mode (do not daemonize, run in foreground). -h Display help and exit. EXIT STATUS
Returns 0 upon success. LICENSE
Copyright (C) 2010-2011, Parallels, Inc. Licensed under GNU GPL. AUTHOR
This manual page was initially written by Thorsten Schifferdecker <tsd@debian.systs.org> for the Debian GNU/Linux system (but may be used by others). OpenVZ 28 Jun 2011 vzeventd(8)