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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Snoop Script tafil Shell Programming and Scripting 2 07-30-2008 03:24 AM
Howto make an URL world readable monkfan UNIX for Dummies Questions & Answers 3 04-11-2007 12:16 PM
Script to move certain number of files every 10 minutes. amitsayshii UNIX for Dummies Questions & Answers 1 02-26-2007 04:55 AM
Howto read data into a shell script banjo Shell Programming and Scripting 4 09-06-2006 07:41 AM
Convert minutes to hours, minutes, seconds Vozx Shell Programming and Scripting 1 12-09-2005 01:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-26-2009
tindasz tindasz is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 6
Need help howto make a script for Set SNOOP run for 5 minutes

Hi all,

I want to monitoring my interface every 6 hours where i want to run snoop command to capture all packet through the interface, so i want running snoop then snoop will run for 5 minutes after that snoop stop then will start again after 6 hours than run for 5 minutes again.

thereis any guide for me how to start that script?
  #2 (permalink)  
Old 05-26-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
use crontab or at command
  #3 (permalink)  
Old 05-26-2009
tindasz tindasz is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 6
ok i try using crontab, that run for every 6 hours but snoop never stop.. i want to make it just running for 5 minutes
  #4 (permalink)  
Old 05-26-2009
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
here is a hint

Code:
run snoop in background
get the background process pid using $!
sleep for 300 seconds
once done, kill $!
then you are done
  #5 (permalink)  
Old 05-26-2009
tindasz tindasz is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 6
get the background process pid using $!

How to get it ?
are u have a sampe of script?
  #6 (permalink)  
Old 05-27-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
Quote:
Originally Posted by tindasz View Post
get the background process pid using $!

How to get it ?
are u have a sampe of script?
this is what you have to do
Code:
 
 snoop &
PID=`echo $!`
sleep 600
kill -9 $PID
  #7 (permalink)  
Old 05-27-2009
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
Quote:
Originally Posted by vidyadhar85 View Post
this is what you have to do
Code:
 
 snoop &
PID=`echo $!`
sleep 600
kill -9 $PID
just this would do
Code:
PID=$!
and no need for an echo command

Code:
kill -2 $PID
Code:
if not kill -9 $PID
no brutal kill in the beginning itself

-----Post Update-----

Quote:
Originally Posted by devtakh View Post
Or you can capture it using grep and awk

Code:
PID=`ps -ef | grep snoop | awk '{print $2}'`
kill -9 $PID
[ $2 or $3 in awk depending on your output]


-Devaraj Takhellambam


there are some problems to this

snoop from other users
grep itself is a process
and the last - when something is available for free in the form of $! you don't have to work on it again
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0