Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Inserting Date&Time Stamp In Existing Log File Post 100081 by shephardfamily on Thursday 23rd of February 2006 03:03:37 PM
Old 02-23-2006
Data

Quote:
Originally Posted by Manish Jha
this could be easily achieved by writing a simple shell script which will read the current processing .. write messages to log file and if failure occurs it will send mail to any group list provided.

Regards,
Manish
I understand that I can write a shell script but what is the syntax to put the time and date in a file and be able to grep all lines below that particular time that I inserted when I am comparing what was there lets say 24 hours ago then pull only those lines. Also, I would like to know how to grep for those lines pulling only the errors generated and place them into a email? Smilie

This is the structure that I have:

#!/bin/sh
# Every 6 hours

# Get all lines from the arlog based on the last PREVIOUS_TIME date and time.

PREVIOUS_TIME='DATE AND TIME: `date`' in the arlog

NEW_TIME='TODAYS DATE AND TIME: `date` ' in the arlog

#LIST OF ERRORS THAT WILL BE SEARCHED.

ERRMSG='CHECKING FOR ERRORS IN ARLOG: ERROR 9999'
ERRMSG1='0403-031 The fork function failed. There is not enough memory available.'
ERRMSG2='Login failed.'
ERRMSG3='ftp: connect: Connection timed out.'
ERRMSG4='ftp: connect: Connection refused.'
ERRMSG5='endeavour: unknown host or invalid literal address.'
ERRMSG6='ftp: Unknown host diamprodf0'
ERRMSG7='ORA-06508: PL/SQL: could not find program unit being called.'
ERRMSG8='ORA-01034: ORACLE not available.'
ERRMSG9='ORA-27101: shared memory realm does not exist.'
ERRMSG10='ORA-01005: null password given; logon denied.'
ERRMSG11='SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL.'
ERRMSG12='ORA-04068: existing state of packages has been discarded.'
ERRMSG13='ORA-04063: package body "FININTER.HAP_CUSTOMERS_INTERFACE" has errors.'
ERRMSG14='ORA-06512: IN LINE ERROR.'
ERRMSG15='ORA-01005: null password given.'

grep 'DATE STAMP: $PREVIOUS_TIME ' arlog >> TEMP_ARLOG.log

if $NEW_TIME in the arlog NOT EQUAL $PREVIOUS_TIME in arlog
then
egrep "(${ERRMSG} | ${ERRMSG1} | ${ERRMSG2} |........) from arlog.
if NO ERRORS EXIST
then
put $NEW_TIME 'No Errors To Date and time" >> arlog
else
mailx -s '$ERRORS `date` to [FMT] with message describing error or errors.
grep 'LAST TIME TRANSMISSION:' $PREVIOUS_TIME >> arlog
fi
fi

Now how do I put the code into a structure that will generate what I want to do above? Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File date and time stamp

I have to capture the creation date and time stamp for a file. The ls command doesn't list all the required information. I need year, month, day, hour, minute and second. Any ideas... (1 Reply)
Discussion started by: Xenon
1 Replies

2. Shell Programming and Scripting

Extract info from log file and compute using time date stamp

Looking for a shell script or a simple perl script . I am new to scripting and not very good at it . I have 2 directories . One of them holds a text file with list of files in it and the second one is a daily log which shows the file completion time. I need to co-relate both and make a report. ... (0 Replies)
Discussion started by: breez_drew
0 Replies

3. Linux

rename files in a folder with date&time stamp

Hi, I want to rename all the files (more than 100 files) in a fodler to another folder with date&time stamp. foe eg, file1.dat file2.dat file3.dat .. to be renamed as file1100629_16_30_15.txt (yy-mon-dd_hh_mi_ss) file1100629_16_30_16.txt .. so on (2 Replies)
Discussion started by: feroz
2 Replies

4. UNIX for Dummies Questions & Answers

ls -ltr for a future date/time stamp file

Hi When i do ls -ltr <file1> then it shows me the date and time of the file if - for whatever reason file has future date/time stamp then ls -ltr is not showing the time, it just shows only date part ... even if time is ahead by 2 hr than current time. suppose a file was copied from INDIA... (3 Replies)
Discussion started by: reldb
3 Replies

5. Shell Programming and Scripting

Set date and time stamp of one file to another

Hi I use "touch -t xxxxxxxx" command to set date/time stamp of a file. My requirement is to read the date/time stamp of a file and apply it to another file. Is there anyway to do it simple instead of manually taking date/stamp of first file? TIA Prvn (2 Replies)
Discussion started by: prvnrk
2 Replies

6. Shell Programming and Scripting

If(Condition) Rename a file with (Date+Time) Stamp

Hi! Please see our current script: #!/usr/bin/ksh if (egrep "This string is found in the log" /a01/bpm.log) then mailx -s "Error from log" me@email.com, him@email.com </a01/bpm.log fi To the above existing script, we need to add the following change: 1) After finding the string,... (7 Replies)
Discussion started by: atechcorp
7 Replies

7. Shell Programming and Scripting

How to extract latest file by looking at date time stamp from a directory?

hi, i have a Archive directory in which files are archived or stored with date and time stamp to prevent over writing. example: there are 5 files s1.txt s2.txt s3.txt s4.txt s5.txt while moving these files to archive directory, date and time stamp is added. of format `date... (9 Replies)
Discussion started by: Little
9 Replies

8. Shell Programming and Scripting

Shell Script | Parse log file after a given date and time stamp

I am developing one script which will take log file name, output file name, date, hour and minute as an argument and based on these inputs, the script will scan and capture all the error(s) that have been triggered from a given time. Example: script should capture all the error after 13:50 on Jan... (2 Replies)
Discussion started by: ROMA3
2 Replies

9. Shell Programming and Scripting

Change date time stamp of existing file

I have a file hello.txt which was created today (today's date timestamp) I wish to change its date timestamp (access, modified, created) to 1 week old i.e one week from now. uname -a SunOS mymac 5.11 11.2 sun4v sparc sun4v Can you please suggest a easy way to do that ? (12 Replies)
Discussion started by: mohtashims
12 Replies

10. Shell Programming and Scripting

Add current time stamp column in existing csv file

Hi , I want to add a new column 'current_time stamp' in my existing csv file with current time stamp for all the records.I tried something this but this is printing 0 with date & time and printed date one line above header.Please help awk -F "," 'BEGIN{ OFS="," } {$6=system("date... (5 Replies)
Discussion started by: netdbaind
5 Replies
ALEVT-DATE(1)							   Teletext time						     ALEVT-DATE(1)

NAME
alevt-date - display/set time received via Teletext SYNOPSIS
alevt-date [options] DESCRIPTION
alevt-date displays the time received from a Teletext source. It can be used to set the system time. The date is not interpreted (not even transmitted on most channels). So it allows only adjustment of +/-12 hours. The default allowed adjustment is limited to +/-2 hours (use -delta to change). Without the -set option it just displays the date in the format of the date(1) command. OPTIONS
A summary of options is included below. -set Set system time from time received via Teletext. -delta seconds Maximum allowed adjustment made to the system time. The default is 7200 seconds (2 hours) and the maximum that may be given is 12 hours. -format string Format string to used to print the time. Look at strftime(3) for possible control sequences. -vbi device Use the given device name. Default: /dev/vbi, /dev/vbi0, /dev/video0, /dev/dvb/adapter0/demux0 tried in this order. -timeout seconds If the time can't be detected in seconds, the program is terminated with a SIGALRM. -progname name Specifies the program name if using the DVB interface. -pid pid Specifies the teletext PID if using the DVB interface. --help Show summary of options. --version Show version of program. Before starting this program, you have to set the TV channel with another program like xawtv of set-tv. Note: This program does not set the battery backed up clock of your computer. clock -w will do this. The -progname or -pid option specifies the program or teletext PID if using the DVB interface. If neither of these two options is used, alevt outputs informations about the currently accessible streams and uses the first of these PIDs as default. This output contains the PIDs and names that can be used as an input for the -progname or -pid option in the context of the currently chosen TV channel. FILES
/dev/vbi* /dev/dvb/adapter*/demux* SEE ALSO
alevt(1x), alevt-cap(1), strftime(3), date(1), clock(8). BUGS
This program is just a toy. The time transmitted by the TV stations is more than inaccurate. Some are within a few seconds of your local time reference but others are more then 15 minutes off. You've been warned. (And don't assume the pkt8/30 time is better. It's even worse.) No bug reports to <froese@gmx.de> *g*. LINUX
1.6.2 ALEVT-DATE(1)
All times are GMT -4. The time now is 02:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy