snoop script in background


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting snoop script in background
# 1  
Old 07-23-2012
snoop script in background

Hi
I want to write a script for snoop which can do snoop for 30 min and then process should be killed automatically

I am using below codes

Code:
#!/usr/bin/ksh
snoop -d igb0 -o /opt/temp/abc.pcap
sleep 1500
kill -9 `ps -ef|grep -i snoop |grep -v grep|awk '{print $2}'`

But process is not getting killed .Can anyone help me for above requirement.
# 2  
Old 07-23-2012
Can you try executing the
Code:
 ps -ef|grep -i snoop |grep -v grep|awk '{print $2}'

and see what is the output that u get!?

Also try to see whether that just returns one ID which is its process ID!!
# 3  
Old 07-23-2012
Its returning process ID

Code:
>ps -ef | grep -i snoop
    root 26288 21712   0 11:33:48 pts/2       0:00 sh snooptest.sh
    root 26303 23695   0 11:33:52 pts/3       0:00 grep -i snoop
  nobody 26289 26288   0 11:33:48 pts/2       0:00 snoop -q -d igb0 -o /opt/temp/abc.pcap

> ps -ef | grep -i snoop | grep -v grep | awk '{print $2}'
26288
26289

but sometimes it is not able to kill the process and process is running in background
# 4  
Old 07-23-2012
For this you have to grep for /opt/temp/abc.pcap so that it just gives you single ID!! Hope this will help! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

2. Shell Programming and Scripting

running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the... (3 Replies)
Discussion started by: maitree
3 Replies

3. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

4. Shell Programming and Scripting

Script to capture snoop output

Hi Everyone :), Need your advice as I'm new to UNIX scripting.. I'm trying to write a script to capture snoop output for 5 minutes for every hour for 24 hours. To stop snoop, I need to press Control-C to break it. This is what I got so far, but now I'm stuck! :confused: The script: # cat... (2 Replies)
Discussion started by: faraaris
2 Replies

5. Solaris

Snoop perl script

Hi , I would like to write a perl script with the snoop command to capture packets from a specific IP address to a node (incoming packets) and packets from that node for the same session to another node and save the capture to a file. I would like my script to be able to read my IP all the time... (7 Replies)
Discussion started by: Pouchie1
7 Replies

6. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

7. Shell Programming and Scripting

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... (9 Replies)
Discussion started by: tindasz
9 Replies

8. Shell Programming and Scripting

Snoop Script

Hi, I want to write a script that checks an interface with the snoop command, if there is no traffic in 10 minutes on port 123 from the ip add 10.*.*.* it should send a e-mail.but i don't know how to start writing this script does anybody have an idea or an sample script that i can modifi. ... (2 Replies)
Discussion started by: tafil
2 Replies

9. Shell Programming and Scripting

Background execution of a script

Hi All, Have a script called FTPIN-xx.sh. It does stuff and when all is done, it is to execute another. However, I'd like to have it execute the second script in the background or in a fashion that would allow my script to complete without having to wait. I'm robbing the command from how I... (2 Replies)
Discussion started by: Cameron
2 Replies

10. Shell Programming and Scripting

how to run script at background

Hi all, I have a script like: echo Please input list file name: read listn for file in `cat $listn.txt` do send_file $file done normally, I will run the script like: :. resendfile Please input list filename: list1 #Then, the script will resend all file from the list1. However,... (4 Replies)
Discussion started by: happyv
4 Replies
Login or Register to Ask a Question