Sponsored Content
Full Discussion: Help with script logic.
Top Forums Shell Programming and Scripting Help with script logic. Post 302349216 by ezmethod on Monday 31st of August 2009 10:42:26 AM
Old 08-31-2009
Java Help with script logic.

Hello everyone, I'me new to shell scripting and have been trying to create a custom script to do the following steps -

1. search for the word servicedown within all log files in a specific directory
2. After finding the keyword servicedown, grab latest timestamp from that log
3. Set variable with results from #2
4. loop previous log files and grab the timestamp from the last line from next newest log in that directory.
5. Set a variable with the results from #4
5. Calculate difference between the 2 timestamps in minutes.

Here is what I have so far, and it's very incomplete. I've been trying to piece this script together as best as I can and could really use any help I can get.

Code:
#!/sw/bin/bash


LogFile="abc.server-ny-abc01.200908270000+0000.log"

LogFile2="$(ls -lt /abc01/ihost/log/abc*log|/sw/bin/grep -v abc.log|/sw/bin/grep -A 1 $LogFile| /sw/bin/tail -n 1| /sw/bin/sed -n "s/.*\(abc\..*\)/\1/p")"

/sw/bin/tail -n 1 /abc01/imail/log/$LogFile2 | /sw/bin/awk '{print "Crash Start",substr($0,1, 13)}'
/sw/bin/grep -i "servicedown" /abc01/ihostlog/abc.log | /sw/bin/awk '{print "Crash End",substr($0,1, 13)}'

exit 0


Here is the current format of the logfiles being generated.-
abc.server-ny-abc01.200908270000+0000.log

Last edited by ezmethod; 08-31-2009 at 12:10 PM..
 

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script logic

Please help me to write the following script. 1) Input files will be in Test directory. (Test/YYYY/MM) folders (Ex: 1) 2010/ 01 2) 2011/05) The file name will be Testfile1_6676543218_Axxxxxxyyyyyzzzzzzzzzzzzzzzzzz.pdf.gz 2) The compare file will be in /tmp directory. (/tmp/comparefile.txt). The... (6 Replies)
Discussion started by: mnjx
6 Replies

2. Shell Programming and Scripting

Need script logic

i have two csv files (rates.csv, reference.csv) as below. rates.csv contains Code, respective Zone details rates.csv ---------- 23,38Nhava 45,37NEWYORK 89,SHILANG 71,ROBACCA reference.csv contains all Zone details reference.csv ------------- 37Newyork robacca 38Nhava... (5 Replies)
Discussion started by: p_satyambabu
5 Replies
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/ksh93, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/ksh93, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh, and /usr/sfw/bin/zsh. /etc/shells overrides the default list. Invalid shells in /etc/shells could cause unexpected behavior, such as being unable to log in by way of ftp(1). FILES
/etc/shells list of shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.11 20 Nov 2007 shells(4)
All times are GMT -4. The time now is 02:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy