passing a paramater to the log file

Reply

Join Date: Jan 2009
Posts: 14
Reputation: madurai07 is an unknown quantity at this point 
Solved Threads: 0
madurai07 madurai07 is offline Offline
Newbie Poster

passing a paramater to the log file

 
0
  #1
Jan 29th, 2009
Shell Scripting Syntax (Toggle Plain Text)
  1. #!/bin/bash
  2. # Days and Procs declaration
  3. DAYS="3"
  4. PROCS="dyyno"
  5.  
  6. # 3 days Old date
  7. AGO=$(date --date="$DAYS days ago" +"%b %d")
  8.  
  9. # Getting pids
  10. PIDS=$(ps eaxo bsdstart,cmd,pid | egrep "^$AGO"' | egrep "$PROCS" | awk '{ print $4}')
  11.  
  12. # killing the processes
  13. echo "Killing $PROCS process created $AGO days ago"
  14. kill -9 $PIDS
  15.  


here i wanted to take the log file associated with the running process (dyyno process) and pass a parameter "0"


Can anyone help me pls@@


Thnxxx in advance
Last edited by Ancient Dragon; Jan 31st, 2009 at 8:42 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: passing a paramater to the log file

 
0
  #2
Jan 29th, 2009
Hey there,

I'm sure what you're shooting for but, maybe:

Shell Scripting Syntax (Toggle Plain Text)
  1. LOG=${PROCS}.log
  2.  
  3. $LOG "0"

or

Shell Scripting Syntax (Toggle Plain Text)
  1. echo "0" >>$LOG

Other than that, I'll need more specifics.

Best wishes,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 14
Reputation: madurai07 is an unknown quantity at this point 
Solved Threads: 0
madurai07 madurai07 is offline Offline
Newbie Poster

Re: passing a paramater to the log file

 
0
  #3
Jan 30th, 2009
Thnxxx Mike... This is my question
I want to write a shell script that kills all processes that satisfy the following conditions:

a. The process is > 3 days old.
b. A log file associated with the process reports a particular parameter as "0"
c. The process name is "dyyno"


this is what i wanted to do... here i am unable to find the log file associated with the particular process!!! Can you help me
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: passing a paramater to the log file

 
0
  #4
Jan 31st, 2009
Hey, ok, I see where you're coming from now

Actually, if you don't know where a particular process logs to, figuring that out from the process itself can be done, but it's not necessarily simple (although, hey, sometimes it is).

I would suggest that you do the log search prior to killing the PIDS associated with the process. Probably the best tools to use (although they may be a bit bulky) would be "lsof" or "truss" ("strace, xtrace, etc, all the same pretty much - depends on your distro of Linux or Unix).

In lsof you could do a simple

lsof|grep PID
and then sift through that output to find any open files associated with the process (eyeball it first and then script the grep out)

for truss, strace, xtrace, etc try doing (I'll use truss for an example, but check the man page for whatever statement-tracing or execution tracing software your distro comes with:

truss -f -p PID|egrep -i 'open|read|write|close'
and check out what files it opens and writes to and then script that out, after watching it manually.

Hopefully that helps. It might be difficult to get it, but it can be done. And, like I said, it might be really simple.

Oh, yes, one last thing - if you know the location of the program, you can run "strings" against it and probably find out where it logs to from that output:

strings /full/path/to/dyyno
Best wishes,

Miek
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC