The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep using date format ali560045 Shell Programming and Scripting 8 12-11-2007 03:39 PM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 05:42 PM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 08:30 PM
Date format: Khoomfire UNIX for Advanced & Expert Users 1 02-13-2006 06:44 AM
date format big123456 Shell Programming and Scripting 2 07-22-2005 01:57 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-24-2007
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
grep using date format

i have few persistance apps like below

pipe 1118370 1200312 0 Dec 18 - 192:03 java - _AppName=DBSyncController

pipe 2523376 1568906 0 feb 25 - 386:15 java -Xms128m -Xmx1024m -D_AppName=DBMaint com

pipe 7462996 2531452 0 march 18 - 23:22 java -D_AppName=Interpolation

pipe 3379242 7631092 0 may 18 - 27:50 java -D_AppName=Archiver2
-----------------------------------------------------------------------

i want to grep these apps using the above date format.i have written the script but its showing me todays date as dec 24

#!/bin/ksh

if test -f dates
then
rm dates
else
echo " "
fi

for i in DBSyncController DBSyncControllerRerun Archiver1 DBSyncListener Archiver2 Cleaner1 Interpolation
do
a=0
a=`date +"%h %d"`
echo $a "\t" $i >> dates
done
echo "--------------------------------------------------------------------------------------------------------------------" >> dates


for i in DBSyncController DBSyncControllerRerun Archiver1 DBSyncListener Archiver2 Cleaner1 Interpolation
do
a=0
a=`date +"%h"`
ps -aef | grep java | grep "$a" | grep $i >> dates
done
----------------------------------------------------------------------

i think some problem in date logic,help me in this
Reply With Quote
Forum Sponsor
  #2  
Old 12-24-2007
Registered User
 

Join Date: Aug 2007
Posts: 45
I didn't Understand what you mean above date format. Do you mean
Mount Day - hour:second. What about the other date format that you don't want to catch in your ps -ef command. Besides that you can not use
date in this example date means todays date. if you send your ps -ef command's output which shows the date format that you want to catch and also the ones you dont want to catch together we can find the solution
Reply With Quote
  #3  
Old 12-24-2007
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
Your requirements are somewhat unclear. If you want to capture the date in the
format outputted by ps, here is one way of doing it.

Create a file (e.g. date.awk) containing the following lines

Code:
  /java/ && /DBSyncController/ { print $5, $6 }
  /java/ && /DBSyncControllerRerun/ { print $5, $6 }
  /java/ && /Archiver1/ { print $5, $6 }
  /java/ && /DBSyncListener/ { print $5, $6 }
  /java/ && /Archiver2/ { print $5, $6 }
  /java/ && /Cleaner1/ { print $5, $6 }
  /java/ && /Interpolation/ { print $5, $6 }
and then replace your loop with

Code:
ps -aef | awk -f date.awk >> dates
Reply With Quote
  #4  
Old 12-25-2007
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
actually wats the date format to be used ,if date is like march 20,feb 12.and like wise

how do u grep this word in below logic

a=`date +"%h %d"`
Reply With Quote
  #5  
Old 12-26-2007
Registered User
 

Join Date: Aug 2007
Posts: 45
outputs of ps are columns of strings,parameters. You can not use date as you intend, you must use a way like fmurphys. Firts send all or a sample part of output oF ps -ef with no grep " I mean ps -ef " . Point out our underline the lines that you want. After this say what will you do with this output. Then I thing the solution will be simple
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0