Script to read a log file and run 2nd script if the dates match


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to read a log file and run 2nd script if the dates match
# 1  
Old 09-18-2012
Script to read a log file and run 2nd script if the dates match

Code:
# cat /tmp/checkdate.log
SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012
Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production

FIRST_TIME           NEXT_TIME
-------------------- --------------------
16-SEP-2012 09:02:49 16-SEP-2012 09:47:15
16-SEP-2012 09:02:49 16-SEP-2012 09:47:15
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production

Code:
# tail  /tmp/checkdate.log | grep "2012" | awk '{print substr($1,1,2), substr($1,4,3), substr($1,8,4)}'
16 SEP 2012
16 SEP 2012

I'm looking for a way to match date to day the script is ran. if the dates match i want it to start another script. can someone help me?

Roger

Last edited by Franklin52; 09-19-2012 at 04:55 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 09-18-2012
Code:
 
tail logfile | grep ":.*:" | awk '{printf $1 " ";} END {print "";}' | read d1 d2
[[ $d1 = $d2 ]] && run_second_script

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

To run the script based on dates

I am having below script which needs to be executed based on start and end date #!/bin/bash array=('2016-09-27' '2016-10-27' '2016-11-27' '2016-12-27' '2017-01-27' '2017-02-27' '2017-03-27' '2017-04-27' '2017-05-27' '2017-06-27' '2017-07-27' '2017-08-27' '2017-09-27' ) for i in "${array}" do... (9 Replies)
Discussion started by: rohit_shinez
9 Replies

3. Shell Programming and Scripting

Script to read file and run multiple jobs

I have a txt file line1 line2 line3 $!/bin/sh cat /tmp/lus.txt | while read line do esxcli storage vmfs unmap -u $lin -n 4000 done this works but does in one line at a time. how do I do all lines at once simutaeously? Please use CODE tags as required by forum rules! (4 Replies)
Discussion started by: tdubb123
4 Replies

4. Shell Programming and Scripting

Read xml file till script finds separation and run again for next input and so on

Hi All, I have one query, I managed to run script with user inputs through command line or with 1 file. But I need to read a txt file/xml file in which user can mention multiple sets of answers and script should run for each set till it reach the EOF. Thanks in advance for example, the file... (3 Replies)
Discussion started by: rv_champ
3 Replies

5. UNIX for Advanced & Expert Users

Script to read log file

Hi, Im looking for a shell script which will search for a particular string in a log file as below scenario 1. I need to run URL http://localhost/client/update?feedid=200 in shell script at(eg)4:00 PM which will not take more than 15 mins to complete. 2. After 15 mins i need to... (6 Replies)
Discussion started by: Paulwintech
6 Replies

6. Shell Programming and Scripting

script to constantly read the last 500 new logs in a log file

Hello, I would like to write a bash script that would monitor a log file for a certain number of logs, let's say 500 logs and when it reaches that number to write the last log to another file. For example, I want to watch the /var/adm/messages and everytime, there is 500 new logs that are... (1 Reply)
Discussion started by: Pouchie1
1 Replies

7. Shell Programming and Scripting

Unix script help to read log file

Hi I have a big log file :08,936 DEBUG HttpConnectionManager.getConnection: config = 11:39:08,936 DEBUG Getting free connection, 11:39:08,989 DEBUG Freeing connection, hostConfig=HostConfiguration 11:39:08,989 DEBUG Notifying no-one, there are no waiting threads 11:39:09,046... (4 Replies)
Discussion started by: javaholics
4 Replies

8. Shell Programming and Scripting

Help w/ script to read file and parse log message

Hi, I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***... The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE. Can anyone give help? Thanks (2 Replies)
Discussion started by: shyork2001
2 Replies

9. Shell Programming and Scripting

Need script to generate all the dates in DDMMYY format between 2 dates

Hello friends, I am looking for a script or method that can display all the dates between any 2 given dates. Input: Date 1 290109 Date 2 010209 Output: 300109 310109 Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies

10. UNIX for Dummies Questions & Answers

cron script -run every 2nd day of month except Monday

I know I can't schedule this in cron and would have to write a wrapper around my script and schedule it in cron ....but not sure how do to this? How do I exclude Monday if the 2nd day of the month falls on a Monday? Thanks. I tried this: 0 0 2 * 0,2-6 command And I know this doesnt... (2 Replies)
Discussion started by: newtou
2 Replies
Login or Register to Ask a Question